Skip to content
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

Issue 9082: Broker expires messages one at a time after topic unload #9083

Merged
merged 13 commits into from
Jan 7, 2021

Conversation

eolivelli
Copy link
Contributor

@eolivelli eolivelli commented Dec 29, 2020

Fixes #9082

Motivation

In case of topic unload the ManagedLedger rolls a new ledger and this confuses the search for messages to be expired.

This is how OpFindNewest (the operation involved in message expiry, PersistentMessageExpiryMonitor) works:

  • first check if first message is expired
  • test in the last message
  • perform a search...

At step two we are jumping to a position that is not valid, and the search ends immediately, returning only the first message

Modifications

Ensure that we are jumping only to a valid position, this change allows the PersistentMessageExpiryMonitor to find the best range of messages to expire.

Verifying this change

This change added tests:

  • unit test that covers the change
  • one reproducer for the problem, that now is fixes
  • another test case for the expected end-to-end behaviour for a consumer that waits too much and messages expire

It can be also verified trying to reproduce manually the reproducer at #9082, after applying this patch the issue is no more reproducible

@eolivelli
Copy link
Contributor Author

Notes for the reviewers:
I am not sure we should fix only OpFindNewest, or if we should enter into getPositionAfterN
A change into getPositionAfterN will be more invasive, I am not sure it is worth to risk.

Copy link
Contributor Author

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @sijie for your review.

I have pushed a commit in order to address some of your comments, I left answers/question to the unresolved comments

@sijie
Copy link
Member

sijie commented Dec 30, 2020

@eolivelli left my comments.

@sijie sijie added this to the 2.8.0 milestone Dec 30, 2020
@eolivelli
Copy link
Contributor Author

@sijie I have just left one of your comments to address, probably I still do not understand how can enhance the test with lastMessageId

.subscribe();

MessageId lastMessageIdOnConsumer = consumer.getLastMessageId();
log.info("lastMessageID written {}, lastMessageIdForConsumer {}", lastMessageId, lastMessageIdOnConsumer);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these two values are the same, even if the messages are expired

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I think you can get stats-internal to get the internal stats to get the markDeletePosition. If you see the markDeletePosition is moved, it means TTL is taking effect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very good @sijie
I have updated the test

@eolivelli
Copy link
Contributor Author

@sijie can you please take another look ? I answered to your comments

@eolivelli eolivelli requested a review from sijie January 7, 2021 08:30
@eolivelli
Copy link
Contributor Author

/pulsarbot run-failure-checks

@sijie sijie merged commit 7313b34 into apache:master Jan 7, 2021
@eolivelli eolivelli deleted the fix/expire-more-messages branch January 8, 2021 07:42
codelipenghui pushed a commit that referenced this pull request Jan 28, 2021
…9083)

Fixes #9082

In case of topic unload the ManagedLedger rolls a new ledger and this confuses the search for messages to be expired.

This is how OpFindNewest (the operation involved in message expiry, PersistentMessageExpiryMonitor) works:
- first check if first message is expired
- test in the last message
- perform a search...

At step two we are jumping to a position that is not valid, and the search ends immediately, returning only the first message

Ensure that we are jumping only to a valid position, this change allows the PersistentMessageExpiryMonitor to find the best range of messages to expire.

This change added tests:
- unit test that covers the change
- one reproducer for the problem, that now is fixes
- another test case for the expected end-to-end behaviour for a consumer that waits too much and messages expire

It can be also verified trying to reproduce manually the reproducer at #9082, after applying this patch the issue is no more reproducible

(cherry picked from commit 7313b34)
@codelipenghui codelipenghui added the cherry-picked/branch-2.7 Archived: 2.7 is end of life label Jan 28, 2021
zymap pushed a commit that referenced this pull request Mar 2, 2021
…9083)

Fixes #9082

In case of topic unload the ManagedLedger rolls a new ledger and this confuses the search for messages to be expired.

This is how OpFindNewest (the operation involved in message expiry, PersistentMessageExpiryMonitor) works:
- first check if first message is expired
- test in the last message
- perform a search...

At step two we are jumping to a position that is not valid, and the search ends immediately, returning only the first message

Ensure that we are jumping only to a valid position, this change allows the PersistentMessageExpiryMonitor to find the best range of messages to expire.

This change added tests:
- unit test that covers the change
- one reproducer for the problem, that now is fixes
- another test case for the expected end-to-end behaviour for a consumer that waits too much and messages expire

It can be also verified trying to reproduce manually the reproducer at #9082, after applying this patch the issue is no more reproducible

(cherry picked from commit 7313b34)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broker expires messages one at a time after topic unload
4 participants