Skip to content

Commit

Permalink
Fix assertion failure while closing remoteStore
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Kale <[email protected]>
  • Loading branch information
Sachin Kale committed Oct 16, 2023
1 parent 01a6ffd commit d4c2011
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion server/src/main/java/org/opensearch/index/IndexService.java
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,15 @@ private void closeShard(String reason, ShardId sId, IndexShard indexShard, Store
}

if (remoteStore != null && indexShard.isPrimaryMode() && deleted.get()) {
remoteStore.close();
// When an instance of Store is created, a shardlock is created which is released on closing the instance of store.
// Currently, we create 2 instances of store for remote store backed indices: store and remoteStore.
// As there can be only one shardlock acquired for a given shard, the lock is shared between store and remoteStore.
// This creates an issue when we are deleting the index as it results in closing both store and remoteStore. At the time
// of closure of second Store instance, we get the assertion error saying shard is not locked.
// Ideally, we should be closing the remoteStore but until we work on CompositeStore
// (https://github.com/opensearch-project/OpenSearch/issues/3719), we mitigate the test failures by
// closing the remoteDirectory.
indexShard.getRemoteDirectory().close();
}

} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1975,7 +1975,7 @@ public void close(String reason, boolean flushEngine, boolean deleted) throws IO
/*
ToDo : Fix this https://github.com/opensearch-project/OpenSearch/issues/8003
*/
private RemoteSegmentStoreDirectory getRemoteDirectory() {
public RemoteSegmentStoreDirectory getRemoteDirectory() {
assert indexSettings.isRemoteStoreEnabled();
assert remoteStore.directory() instanceof FilterDirectory : "Store.directory is not an instance of FilterDirectory";
FilterDirectory remoteStoreDirectory = (FilterDirectory) remoteStore.directory();
Expand Down

0 comments on commit d4c2011

Please sign in to comment.