Skip to content

Commit

Permalink
Compute shardStateId before addAbortListener (#100809) (#100832)
Browse files Browse the repository at this point in the history
It is not valid to call `SnapshotIndexCommit#indexCommit()` if the
snapshot is aborted, so we must compute `shardStateId` before adding the
abort listener.

Closes #99477
  • Loading branch information
DaveCTurner authored Oct 13, 2023
1 parent c552203 commit 6507f57
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ private void snapshot(
SnapshotIndexCommit snapshotIndexCommit = null;
try {
snapshotIndexCommit = new SnapshotIndexCommit(indexShard.acquireIndexCommitForSnapshot());
final var shardStateId = getShardStateId(indexShard, snapshotIndexCommit.indexCommit()); // not aborted so indexCommit() ok
snapshotStatus.addAbortListener(makeAbortListener(indexShard.shardId(), snapshot, snapshotIndexCommit));
snapshotStatus.ensureNotAborted();
repository.snapshotShard(
Expand All @@ -392,7 +393,7 @@ private void snapshot(
snapshot.getSnapshotId(),
indexId,
snapshotIndexCommit,
getShardStateId(indexShard, snapshotIndexCommit.indexCommit()),
shardStateId,
snapshotStatus,
version,
entryStartTime,
Expand Down

0 comments on commit 6507f57

Please sign in to comment.