[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.
what about adding a DEBUG statement here ?
There was a problem hiding this comment.
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.
what about adding a DEBUG statement here ?
There was a problem hiding this comment.
there would be a lot of logging since it's very common that it would happen.
There was a problem hiding this comment.
then we can add DEBUG in the other branch, the "new" code that you are adding
There was a problem hiding this comment.
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.
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. |
…#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
lastMarkDeleteEntrycan lead to the subscription and consuming getting stuck. This seems to impact both Key_shared and Shared subscriptions.Modifications
lastMarkDeleteEntryfield, make sure that the new value is later than the previous value.