Skip to content

Commit 7678eb3

Browse files
authored
Delete persisted cold cache index if created in the future (#120465) (#120467)
The Lucene index used to store cold cache files information (to persist the cold cache across node restarts) is upgraded at node startup, before the cluster is formed. This upgrade can become an issue if the node cannot join the cluster: an attempt to downgrade the node back to the previous version will likely fail due to this Lucene index being already upgraded. Ideally we would prefer to upgrade the Lucene index after the node joined the cluster, but it requires more work as this Lucene index can be queried concurrently during shard allocation (see TransportSearchableSnapshotCacheStoresAction). Instead of doing a more involved fix, this change deletes the persistent cache index from disk if it detects that the Lucene index has been upgraded. It assumes that we are already in a best effort downgrading procedure, so losing persistent cache is acceptable in order to allow downgrading the node.
1 parent 0de3d12 commit 7678eb3

File tree

1 file changed

+10
-0
lines changed
  • x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/cache/full

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,16 @@ static Map<String, Document> loadDocuments(Path directoryPath) throws IOExceptio
434434
} catch (IndexNotFoundException e) {
435435
logger.debug("persistent cache index does not exist yet", e);
436436
}
437+
} catch (Exception e) {
438+
if (e instanceof IllegalArgumentException iae) {
439+
final var message = iae.getMessage();
440+
if (message != null && message.startsWith("indexCreatedVersionMajor is in the future:")) {
441+
logger.warn("Deleting persistent cache index created in the future [message: {}]", message);
442+
IOUtils.rm(directoryPath);
443+
return Map.of();
444+
}
445+
}
446+
throw e;
437447
}
438448
return documents;
439449
}

0 commit comments

Comments
 (0)