-
Notifications
You must be signed in to change notification settings - Fork 11.7k
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
[Summer of Code] Support switch role for ha service #4236
[Summer of Code] Support switch role for ha service #4236
Conversation
Codecov Report
@@ Coverage Diff @@
## 5.0.0-beta-dledger-controller #4236 +/- ##
===================================================================
+ Coverage 43.27% 43.82% +0.55%
- Complexity 6137 6277 +140
===================================================================
Files 818 826 +8
Lines 57559 58520 +961
Branches 7852 7993 +141
===================================================================
+ Hits 24910 25648 +738
- Misses 29412 29586 +174
- Partials 3237 3286 +49
Continue to review full report at Codecov.
|
store/src/main/java/org/apache/rocketmq/store/config/MessageStoreConfig.java
Outdated
Show resolved
Hide resolved
store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/AutoSwitchHAClient.java
Outdated
Show resolved
Hide resolved
store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/AutoSwitchHAClient.java
Outdated
Show resolved
Hide resolved
store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/EpochFileCache.java
Outdated
Show resolved
Hide resolved
store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/AutoSwitchHAConnection.java
Outdated
Show resolved
Hide resolved
store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/AutoSwitchHAConnection.java
Outdated
Show resolved
Hide resolved
store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/EpochFileCache.java
Outdated
Show resolved
Hide resolved
store/src/test/java/org/apache/rocketmq/store/ha/EpochFileCacheTest.java
Show resolved
Hide resolved
store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/EpochFileCache.java
Outdated
Show resolved
Hide resolved
store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/AutoSwitchHAConnection.java
Outdated
Show resolved
Hide resolved
localEpochCache.initCacheFromEntries(this.epochCache.getAllEntries()); | ||
localEpochCache.setLastEpochEntryEndOffset(this.messageStore.getMaxPhyOffset()); | ||
|
||
final long truncateOffset = localEpochCache.findConsistentPoint(masterEpochCache); |
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.
1.如果因为某些原因(比如日志被删除),找不到主备间的一致的点,应该等待人工处理,而不是继续往下走。
2.如果slave是空,是不是可以直接不走截断流程,这里正确的原因主要是找不到主备间的一致的点currentReportedOffset=-1,然后再reportSlaveMaxOffset被修正成0.
store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/AutoSwitchHAConnection.java
Outdated
Show resolved
Hide resolved
store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/AutoSwitchHAClient.java
Show resolved
Hide resolved
public long getConfirmOffset() { | ||
long confirmOffset = this.defaultMessageStore.getMaxPhyOffset(); | ||
for (HAConnection connection : this.connectionList) { | ||
confirmOffset = Math.min(confirmOffset, connection.getSlaveAckOffset()); | ||
} | ||
return confirmOffset; | ||
} |
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.
这个后面还得改,得筛选出在SyncStateSet中的connnection然后比较位点
What is the purpose of the change
tracking issue: #4330
We want unified log replication, using rocketmq's original HaService instead of dledger mode.
Previously, i have done the following job with @RongtongJin
In this pr, I added a haService - AutoSwitchHAService that can switch role, this ha can cooperate with the controller to achieve master-slave switching
In the follow-up work, I will modify the code of the broker to fully realize the master-slave switch
Brief changelog
The ha service protocol is:
Verifying this change
Follow this checklist to help us incorporate your contribution quickly and easily. Notice,
it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR
.[ISSUE #123] Fix UnknownException when host config not exist
. Each commit in the pull request should have a meaningful subject line and body.mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle
to make sure basic checks pass. Runmvn clean install -DskipITs
to make sure unit-test pass. Runmvn clean test-compile failsafe:integration-test
to make sure integration-test pass.