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 #6728] Compute the confirmOffset without considering new connections #6729

Merged
merged 3 commits into from
May 11, 2023

Conversation

GenerousMan
Copy link
Contributor

[ISSUE #6728] Compute the confirmOffset without considering new connections.

Which Issue(s) This PR Fixes

Fixes #6728

Brief Description

  1. When calculate the newConfirmOffset, skip those connections with -1 ackOffset value.
  2. Add a new method, getConfirmOffsetDirectly(). This method will only return the confirmOffset without checking and re-computing. Because in some cases (If set confirmOffset wrongly) endless calling will occur between the getConfirmOffset() and computeConfirmOffset().

How Did You Test This Change?

…ctions. 2. When compute the confirmOffset, use getConfirmOffsetDirectly() to avoid the endless calling.
Comment on lines 432 to 437
long slaveAckOffset = connection.getSlaveAckOffset();
if (slaveAckOffset <= 0) {
// Slave's connection is just inited, the ack hasn't been calculated.
// So skip this ackOffset.
continue;
}
Copy link
Contributor

@echooymxq echooymxq May 10, 2023

Choose a reason for hiding this comment

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

if (currentSyncStateSet.contains(slaveId) && connection.getSlaveAckOffset() > 0) {
 ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I have optimized this logic as you said.

@codecov-commenter
Copy link

Codecov Report

Merging #6729 (52049b0) into develop (09ad52b) will decrease coverage by 0.05%.
The diff coverage is 33.33%.

@@              Coverage Diff              @@
##             develop    #6729      +/-   ##
=============================================
- Coverage      42.88%   42.83%   -0.05%     
+ Complexity      9009     8995      -14     
=============================================
  Files           1113     1113              
  Lines          78587    78601      +14     
  Branches       10221    10224       +3     
=============================================
- Hits           33700    33667      -33     
- Misses         40669    40711      +42     
- Partials        4218     4223       +5     
Impacted Files Coverage Δ
...org/apache/rocketmq/store/DefaultMessageStore.java 47.02% <0.00%> (-0.03%) ⬇️
...main/java/org/apache/rocketmq/store/CommitLog.java 64.01% <33.33%> (-0.48%) ⬇️
...ketmq/store/ha/autoswitch/AutoSwitchHAService.java 51.61% <50.00%> (ø)

... and 32 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@fuyou001 fuyou001 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@mxsm mxsm left a comment

Choose a reason for hiding this comment

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

LGTM~

@RongtongJin RongtongJin merged commit 5dc2e20 into apache:develop May 11, 2023
lyx2000 pushed a commit to lyx2000/rocketmq that referenced this pull request Jun 30, 2023
… connections (apache#6729)

* 1. When compute the confirmOffset, dismiss the ackOffset of new connections. 2. When compute the confirmOffset, use getConfirmOffsetDirectly() to avoid the endless calling.

* use the calculated slaveAckOffset

* optimize the logic.
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.

[Bug] The confirmOffset may be set to -1 due to the new connection
6 participants