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

[fix][broker] Avoid splitting one batch message into two entries in StrategicTwoPhaseCompactor #21091

Conversation

Demogorgon314
Copy link
Member

@Demogorgon314 Demogorgon314 commented Aug 30, 2023

Motivation

Currently, the ServiceUnitStateChannelImpl will send batch messages to loadbalancer-service-unit-state topic,
and the StrategicTwoPhaseCompactor will consume the message and rebatch the message to a new batch.

However, the StrategicTwoPhaseCompactor may write messages from the same batch into different entries, which will result in skipping some messages when reading compacted entries.

For example, we have a batch: [(3:0:-1:0, k1), (3:0:-1:1, k2)], after compact, the batch maybe [3:0:-1:0, k1] and [3:0:-1:0, k2] , then if we only read one entry, the readPosition will be updated to 3:1 , so the [3:0:-1:0, k2] will be skipped.

Modifications

  • Check the add message entryId and ledgerId before adding a message to RawBatchMessageContainerImpl.
  • Remove size limit for RawBatchMessageContainerImpl to let input batch decide.

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

@Demogorgon314 Demogorgon314 self-assigned this Aug 30, 2023
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Aug 30, 2023
@Demogorgon314 Demogorgon314 changed the title [fix][broker] Avoid send batch message to loadbalancer service unit state topic to avoid split message to two batches [fix][broker] Avoid splitting one batch message into two entries in StrategicTwoPhaseCompactor Aug 31, 2023
@@ -90,6 +91,26 @@ public void setCryptoKeyReader(CryptoKeyReader cryptoKeyReader) {
this.cryptoKeyReader = cryptoKeyReader;
}

@Override
public boolean add(MessageImpl<?> msg, SendCallback callback) {
this.lastAddedMessageId = (MessageIdImpl) msg.getMessageId();
Copy link
Contributor

@heesung-sn heesung-sn Aug 31, 2023

Choose a reason for hiding this comment

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

We need to clean this id when we call clear().

@Demogorgon314 Demogorgon314 marked this pull request as ready for review August 31, 2023 09:11
@Demogorgon314 Demogorgon314 force-pushed the Demogorgon314/Avoid-handle-batch-message-in-strategic-two-phase-compactior branch from ee7979c to b9ba3f9 Compare September 1, 2023 02:40
@codecov-commenter
Copy link

Codecov Report

Merging #21091 (08571ad) into master (64d006b) will increase coverage by 0.15%.
Report is 8 commits behind head on master.
The diff coverage is 76.59%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #21091      +/-   ##
============================================
+ Coverage     73.06%   73.22%   +0.15%     
- Complexity    32407    32453      +46     
============================================
  Files          1887     1887              
  Lines        139923   139976      +53     
  Branches      15402    15412      +10     
============================================
+ Hits         102239   102500     +261     
+ Misses        29608    29368     -240     
- Partials       8076     8108      +32     
Flag Coverage Δ
inttests 24.19% <10.63%> (?)
systests 25.11% <5.31%> (+0.04%) ⬆️
unittests 72.51% <76.59%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
...g/apache/pulsar/compaction/CompactedTopicImpl.java 60.71% <0.00%> (-3.20%) ⬇️
.../pulsar/compaction/StrategicTwoPhaseCompactor.java 76.69% <74.07%> (+0.19%) ⬆️
.../apache/pulsar/compaction/CompactedTopicUtils.java 74.46% <80.00%> (+4.46%) ⬆️
...che/bookkeeper/mledger/impl/ManagedLedgerImpl.java 81.35% <83.33%> (+0.01%) ⬆️
...che/bookkeeper/mledger/impl/ManagedCursorImpl.java 79.41% <88.46%> (+0.37%) ⬆️
...lsar/client/impl/RawBatchMessageContainerImpl.java 93.42% <100.00%> (+0.88%) ⬆️

... and 81 files with indirect coverage changes

@Demogorgon314 Demogorgon314 added release/3.0.2 release/3.1.1 type/bug The PR fixed a bug or issue reported a bug area/broker labels Sep 4, 2023
@codelipenghui codelipenghui merged commit e59c850 into apache:master Sep 4, 2023
@Demogorgon314 Demogorgon314 deleted the Demogorgon314/Avoid-handle-batch-message-in-strategic-two-phase-compactior branch September 4, 2023 07:43
Technoboy- pushed a commit that referenced this pull request Sep 5, 2023
Demogorgon314 added a commit to Demogorgon314/pulsar that referenced this pull request Sep 11, 2023
…trategicTwoPhaseCompactor (apache#21091)

(cherry picked from commit e59c850)
Technoboy- pushed a commit to Demogorgon314/pulsar that referenced this pull request Sep 14, 2023
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.

7 participants