-
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] Avoid splitting one batch message into two entries in StrategicTwoPhaseCompactor #21091
Merged
codelipenghui
merged 12 commits into
apache:master
from
Demogorgon314:Demogorgon314/Avoid-handle-batch-message-in-strategic-two-phase-compactior
Sep 4, 2023
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
heesung-sn
reviewed
Aug 31, 2023
pulsar-broker/src/main/java/org/apache/pulsar/compaction/StrategicTwoPhaseCompactor.java
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/compaction/StrategicTwoPhaseCompactor.java
Outdated
Show resolved
Hide resolved
@@ -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(); |
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.
We need to clean this id when we call clear().
heesung-sn
reviewed
Aug 31, 2023
pulsar-broker/src/main/java/org/apache/pulsar/client/impl/RawBatchMessageContainerImpl.java
Outdated
Show resolved
Hide resolved
heesung-sn
reviewed
Sep 1, 2023
...ava/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelImpl.java
Outdated
Show resolved
Hide resolved
Demogorgon314
force-pushed
the
Demogorgon314/Avoid-handle-batch-message-in-strategic-two-phase-compactior
branch
from
September 1, 2023 02:40
ee7979c
to
b9ba3f9
Compare
heesung-sn
approved these changes
Sep 1, 2023
Demogorgon314
requested review from
Technoboy-,
codelipenghui,
gaoran10,
BewareMyPower,
coderzc and
mattisonchao
September 1, 2023 04:13
pulsar-broker/src/main/java/org/apache/pulsar/client/impl/RawBatchMessageContainerImpl.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/client/impl/RawBatchMessageContainerImpl.java
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/client/impl/RawBatchMessageContainerImpl.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/client/impl/RawBatchMessageContainerImpl.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/compaction/StrategicTwoPhaseCompactor.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/compaction/StrategicTwoPhaseCompactor.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/compaction/StrategicTwoPhaseCompactor.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/test/java/org/apache/pulsar/compaction/StrategicCompactionTest.java
Outdated
Show resolved
Hide resolved
coderzc
approved these changes
Sep 1, 2023
pulsar-broker/src/test/java/org/apache/pulsar/compaction/StrategicCompactionTest.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/test/java/org/apache/pulsar/compaction/StrategicCompactionTest.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/test/java/org/apache/pulsar/compaction/StrategicCompactionTest.java
Outdated
Show resolved
Hide resolved
BewareMyPower
approved these changes
Sep 1, 2023
Codecov Report
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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
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
…trategicTwoPhaseCompactor (#21091)
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
…trategicTwoPhaseCompactor (apache#21091) (cherry picked from commit e59c850)
Demogorgon314
added
cherry-picked/branch-3.0
and removed
cherry-picked/branch-3.0
labels
Oct 8, 2023
4 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area/broker
cherry-picked/branch-3.0
cherry-picked/branch-3.1
doc-not-needed
Your PR changes do not impact docs
ready-to-test
release/3.0.2
release/3.1.1
type/bug
The PR fixed a bug or issue reported a bug
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Currently, the
ServiceUnitStateChannelImpl
will send batch messages toloadbalancer-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, thereadPosition
will be updated to3:1
, so the[3:0:-1:0, k2]
will be skipped.Modifications
entryId
andledgerId
before adding a message toRawBatchMessageContainerImpl
.RawBatchMessageContainerImpl
to let input batch decide.Documentation
doc
doc-required
doc-not-needed
doc-complete