-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compute shardStateId before addAbortListener #100809
Compute shardStateId before addAbortListener #100809
Conversation
It is not valid to call `SnapshotIndexCommit#indexCommit()` if the snapshot is aborted, so we must compute `shardStateId` before adding the abort listener. Closes elastic#99477
Pinging @elastic/es-distributed (Team:Distributed) |
This problem was introduced in #96442 and AFAICT it only matters for tests - in practice it's ok to call |
final var shardStateId = getShardStateId(indexShard, snapshotIndexCommit.indexCommit()); // not aborted so indexCommit() ok | ||
snapshotStatus.addAbortListener(makeAbortListener(indexShard.shardId(), snapshot, snapshotIndexCommit)); | ||
snapshotStatus.ensureNotAborted(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need some help to understand why this fix works. The change is to call getShardStateId
before snapshotStatus.addAbortListener
and the goal is to make sure snapshotIndexCommit
is not released when the indexCommit()
method is call against it.
It seems the fix would work if some how snapshotStatus.addAbortListener(...)
immediately calls the added listener which in turn releases snapshotIndexCommit
. This suggests snapshotStatus
is already aborted. But the next line snapshotStatus.ensureNotAborted()
says it must not be aborted already. So I am confused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue is that an abort may happen concurrently, in between calling snapshotStatus.ensureNotAborted()
and snapshotIndexCommit.indexCommit()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right. I always need a prompt for concurrency. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
It is not valid to call `SnapshotIndexCommit#indexCommit()` if the snapshot is aborted, so we must compute `shardStateId` before adding the abort listener. Closes elastic#99477
It is not valid to call `SnapshotIndexCommit#indexCommit()` if the snapshot is aborted, so we must compute `shardStateId` before adding the abort listener. Closes elastic#99477
It is not valid to call
SnapshotIndexCommit#indexCommit()
if thesnapshot is aborted, so we must compute
shardStateId
before adding theabort listener.
Closes #99477