-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[fix] [broker] reader stuck with marker message though hasMessageAvailable() return true #21951
Conversation
* @param lastPosition | ||
* @param ml | ||
*/ | ||
private void readLastValidEntry(CompletableFuture<MessageMetadata> entryMetaDataFuture, |
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.
This will search forward one by one until a valid position is found, not sure about the performance.
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.
If there is an aborted txn with lots of message to be discarded, the search may be time consuming. But time-consuming is better than stucking, right?
As it may impact performance and this corner case may be rare, we close it. |
Motivation
#21718 fix a problem that the compaction reader stuck when meet a marker message, such as transaction marker. The reason why the reader stuck is that
hasMessageAvailable()
rely on thegetLastMessageId
, which return theMessageId
m1
of the marker message, but the server will filter marker message transparently, the reader need to read tom1
until the compaction end, but the server will not dispatch the marker message(m1) to client, so the compaction reader stuck.The solution #21718 take is do not filter such message when the subscription name is
__compaction
, and transfer the responsibility of filtering to user(compaction reader), so that thereadNext
andhasMessageAvailable
is consistent.But, such patch could only fix the problem of compaction, normal users may use such kind of logic to do something.
Modifications
The root cause of such kind of stuck problem is that,
getLastMessageId
do not validate message completely, though it has done some kind of check likemaxReadPosition
.We need to refactor
getLastMessageId
to ensure that message corresponding to the id it return is valid.Verifying this change
(Please pick either of the following options)
This change added tests and can be verified as follows:
(example:)
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: thetumbled#34