-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[ML] Fix race condition in updating lastMarkDeleteEntry field #15031
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
[ML] Fix race condition in updating lastMarkDeleteEntry field #15031
Conversation
- missed updates can lead to the subscription and consuming getting stuck
final Map<String, Long> properties) { | ||
LAST_MARK_DELETE_ENTRY_UPDATER.updateAndGet(this, last -> { | ||
if (last != null && last.newPosition.compareTo(newPosition) > 0) { | ||
// keep current value, don't update |
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.
what about adding a DEBUG statement here ?
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.
let's address logging in the previous case and use a similar resolution here
lastMarkDeleteEntry = mdEntry; | ||
LAST_MARK_DELETE_ENTRY_UPDATER.updateAndGet(this, last -> { | ||
if (last != null && last.newPosition.compareTo(mdEntry.newPosition) > 0) { | ||
// keep the current value since it's later then the mdEntry.newPosition |
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.
what about adding a DEBUG statement here ?
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.
there would be a lot of logging since it's very common that it would happen.
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.
then we can add DEBUG in the other branch, the "new" code that you are adding
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.
Do you mean something like this?
if (log.isDebugEnabled()) {
log.debug("Keeping {} since it's newer than {}", last, mdEntry);
}
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.
or is this better
if (log.isDebugEnabled()) {
log.debug("Ignoring update {} to lastMarkDeleteEntry {} since current value is later", mdEntry, last);
}
btw. The problem scenario looked like very similar as in #14261. However there was a difference. |
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
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.
👍
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
…#15031) - missed updates can lead to the subscription and consuming getting stuck
…apache#15031)" This reverts commit ad2f397.
I made a follow-up PR #15067 to improve the solution. Please review. |
(apache#15067) - follow up on apache#15031 * [ML] Fix race in persisting mark delete position * [ML] Resetting should reset lastMarkDeleteEntry * [ML] Reset fields in initializeCursorPosition method (cherry picked from commit a19a30a)
(apache#15067) - follow up on apache#15031 * [ML] Fix race in persisting mark delete position * [ML] Resetting should reset lastMarkDeleteEntry * [ML] Reset fields in initializeCursorPosition method
…#15031) - missed updates can lead to the subscription and consuming getting stuck
(apache#15067) - follow up on apache#15031 * [ML] Fix race in persisting mark delete position * [ML] Resetting should reset lastMarkDeleteEntry * [ML] Reset fields in initializeCursorPosition method
Why does this patch not add a test ? |
…#15031) (ad2f397) - missed updates can lead to the subscription and consuming getting stuck
Motivation
lastMarkDeleteEntry
can lead to the subscription and consuming getting stuck. This seems to impact both Key_shared and Shared subscriptions.Modifications
lastMarkDeleteEntry
field, make sure that the new value is later than the previous value.