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

[Branch-2.7][Cherry-pick] Return message ID from compacted ledger while the compaction cursor reach the end of the topic. #16395

Merged
merged 1 commit into from
Jul 5, 2022

Conversation

Technoboy-
Copy link
Contributor

@Technoboy- Technoboy- commented Jul 5, 2022

Cherry-pick #13533

Motivation

The problem happens when the compaction cursor reaches the end of the topic but the tail messages
of the topic have been removed by producer writes null value messages during the topic compaction.

For example:

  • 5 messages in the original topic with key: 0,1,2,3,4
  • the corresponding message IDs are: 1:0, 1:1, 1:2, 1:3, 1:4
  • producer send null value messages for key 3 and 4
  • trigger the topic compaction task

After the compaction task complete,

  • 5 messages in the original topic: 1:0, 1:1, 1:2, 1:3, 1:4
  • 3 messages in the compacted ledger: 1:0, 1:1, 1:2

At this moment, if the reader tries to get the last message ID of the topic,
we should return 1:2 not 1:4, because the reader is not able to read the message
with keys 3 and 4 from the compacted topic, otherwise, the reader.readNext() method
will be blocked until a new message written to the topic.

Modifications

The fix is straightforward, when the broker receives a get last message ID request,
the broker will check if the compaction cursor reaches the end of the original topic.
If yes, respond last message ID from the compacted ledger.

Verifying this change

New test added testHasMessageAvailableWithNullValueMessage which ensure the hasMessageAvailable()
return false no more messages from the compacted topic if the compaction cursor reaches the end of the topic.

Does this pull request potentially affect one of the following parts:

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API: (no)
  • The schema: (no)
  • The default values of configurations: (no)
  • The wire protocol: (no)
  • The rest endpoints: (no)
  • The admin cli options: (no)
  • Anything that affects deployment: (no)

Documentation

Check the box below and label this PR (if you have committer privilege).

Need to update docs?

  • doc-required

    (If you need help on updating docs, create a doc issue)

  • no-need-doc

    (Please explain why)

  • doc

    (If this PR contains doc changes)

Sorry, something went wrong.

@Technoboy- Technoboy- self-assigned this Jul 5, 2022
@Technoboy- Technoboy- marked this pull request as ready for review July 5, 2022 08:02
@Technoboy- Technoboy- changed the title [branch-2.7][Cherry-pick] Return message ID from compacted ledger while the compaction cursor reach the end of the topic. [Branch-2.7][Cherry-pick] Return message ID from compacted ledger while the compaction cursor reach the end of the topic. Jul 5, 2022
@Technoboy- Technoboy- merged commit f4ebf08 into apache:branch-2.7 Jul 5, 2022
@Technoboy- Technoboy- deleted the cherry-pick-13533-2 branch August 10, 2022 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants