Skip to content

Commit 1a946e4

Browse files
committed
Make CacheService.get() throws AlreadyClosedException when service is stopped
This is caught thanks to #121210: if shard files are verified/checksumed while the node is stopping, an IllegalStateException is throw by CacheService.get() when it attempts to read data from the cache. This exception later caused the verification to fail and then the Lucene index to be marked as corrupted (which nows fails for searchable snapshots shards that are read-only and should not be corrupted at all). This pull request changes ensureLifecycleStarted(), which is called during CacheService.get(), to throw an AlreadyClosedException when the service is stopped (note that ACE extends IllegalStateException, which is convenient here). This ACE will be later specially handlded in the checksumIndex method to not mark the shard as corrupted (see #121210). Closes #121927
1 parent c594067 commit 1a946e4

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,6 @@ tests:
380380
issue: https://github.com/elastic/elasticsearch/issues/121867
381381
- class: org.elasticsearch.xpack.searchablesnapshots.minio.MinioSearchableSnapshotsIT
382382
issue: https://github.com/elastic/elasticsearch/issues/121882
383-
- class: org.elasticsearch.xpack.searchablesnapshots.FrozenSearchableSnapshotsIntegTests
384-
method: testCreateAndRestorePartialSearchableSnapshot
385-
issue: https://github.com/elastic/elasticsearch/issues/121927
386383
- class: org.elasticsearch.analysis.common.CommonAnalysisClientYamlTestSuiteIT
387384
method: test {yaml=analysis-common/40_token_filters/stemmer_override file access}
388385
issue: https://github.com/elastic/elasticsearch/issues/121625

x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/cache/full/CacheService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,11 @@ private void ensureLifecycleStarted() {
245245
final Lifecycle.State state = lifecycleState();
246246
assert state != Lifecycle.State.INITIALIZED : state;
247247
if (state != Lifecycle.State.STARTED) {
248-
throw new IllegalStateException("Failed to read data from cache: cache service is not started [" + state + "]");
248+
if (state == Lifecycle.State.STOPPED) {
249+
throw new AlreadyClosedException("Failed to read data from cache: cache service is stopped");
250+
} else {
251+
throw new IllegalStateException("Failed to read data from cache: cache service is not started [" + state + "]");
252+
}
249253
}
250254
}
251255

0 commit comments

Comments
 (0)