You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trigger explicit loading of blob container and snapshot in the pre-recovery hook (#54729)
In #53961 we defer the construction of Searchable Snapshot
Directory's BlobContainer and a BlobStoreIndexShardSnapshot
instances so that these objects are created when they are first
accessed, which we expect to be during the recovery process. At
the same time, assertions were added to ensure that the
construction is effectively executed under a generic or snapshot
thread.
Sadly, this is not always the case because there is always a
short window of time between the creation of the IndexShard and
the time the objects are created during the recovery process. It
is also possible that other components of Elasticsearch trigger
the creation of the blob container and snapshot.
We identified the following places:
- computing avg shard size of index shards in
IndexService.createShard() (this is triggered when relocating
a primary shard under the cluster state applier thread)
- computing indices stats in TransportIndicesStatsAction which
calls indexShard.storeStats() which calls
estimateSizeInBytes() (this is triggered by
InternalClusterInfoService under the management thread pool)
- computing shard store metadata in
IndexShard.snapshotStoreMetadata while calls
failIfCorrupted(Directory) (this is triggered by
TransportNodesListShardStoreMetadata, executed under the
fetch_shard_store thread pool)
- TransportNodesListGatewayStartedShards should also use
failIfCorrupted(Directory) at some point (triggered by the
GatewayAllocator and executed under the fetch_shard_started
thread pool)
This commit changes the way BlobContainer and a
BlobStoreIndexShardSnapshot instances are created so that it does
not happen on first access anymore but the objects are now
created using a specific loadSnapshot() method.
This method is explicitly called during the pre-recovery phase.
Until this method is called, the SearchableSnapshotDirectory acts
as if it was empty: the listAll() method returns an empty
array. Having this behavior allows the identified access points
to not fail and not trigger the snapshot loading before we
explicitly load it in the pre-recovery hook.
Copy file name to clipboardExpand all lines: x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/index/store/SearchableSnapshotDirectory.java
Copy file name to clipboardExpand all lines: x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotIndexEventListener.java
Copy file name to clipboardExpand all lines: x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/action/AbstractTransportSearchableSnapshotsAction.java
Copy file name to clipboardExpand all lines: x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/index/store/SearchableSnapshotDirectoryStatsTests.java
Copy file name to clipboardExpand all lines: x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/index/store/SearchableSnapshotDirectoryTests.java
Copy file name to clipboardExpand all lines: x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/index/store/cache/CachedBlobContainerIndexInputTests.java
0 commit comments