-
Notifications
You must be signed in to change notification settings - Fork 24.7k
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
Add replica ops with version conflict to translog #22626
Add replica ops with version conflict to translog #22626
Conversation
An operation that completed successfully on a primary can result in a version conflict on a replica due to the asynchronous nature of operations. When a replica operation results in a version conflict, the operation is not added to the translog. This leads to gaps in the translog which is problematic as it can lead to situations where a replica shard can never advance its local checkpoint. As such operations are just normal course of business for a replica shard, these operations should be treated as if they completed successfully. This commit adds these operations to the translog.
7bae49e
to
71b89ef
Compare
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. Thx @jasontedor
@@ -489,8 +486,9 @@ public GetResult get(Get get, Function<String, Searcher> searcherFactory) throws | |||
op.id(), | |||
op.versionType().explainConflictForWrites(currentVersion, expectedVersion, deleted)); | |||
result = onFailure.apply(e); | |||
} else { | |||
result = onSuccess.get(); |
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.
can we add a comment here ? something like "version conflicts during recovery and replica operation are normal and occur due to out of order delivery. we should return a successful result"
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 pushed bbffd87.
@@ -804,18 +804,17 @@ private DeleteResult innerDelete(Delete delete) throws IOException { | |||
|
|||
final long expectedVersion = delete.version(); | |||
|
|||
final Optional<DeleteResult> result = | |||
final Optional<DeleteResult> checkVersionConflictResult = |
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.
nit: shall we call this resultOnVersionConflict? also - it would be good to do the same in innerIndex
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 pushed d40aa07.
This commit adds a comment explaining why version conflicts during recovery and on replicas are considered normal and thus why we return a successful result.
This commit renames the local variable used to store the result of checking whether or not there is a version conflict.
Thanks @bleskes. |
An operation that completed successfully on a primary can result in a version conflict on a replica due to the asynchronous nature of operations. When a replica operation results in a version conflict, the operation is not added to the translog. This leads to gaps in the translog which is problematic as it can lead to situations where a replica shard can never advance its local checkpoint. As such operations are just normal course of business for a replica shard, these operations should be treated as if they completed successfully. This commit adds these operations to the translog.