qsrg commented on issue #3388:
URL: https://github.com/apache/rocketmq/issues/3388#issuecomment-929833299
Before start up the slave,check the commigLog data is correctly by manual is
inconvenient to execute 。From the machine of slave broke down to it repaired,we
did not modify the data in the store directory of slave,this mistake maybe due
to the deletion policy or other reasons.
add the following checks when master received slaveRequestOffset at
first,if slaveRequestOffset>maxOffset or slaveRequestOffset<minOffset,send last
commitLog file. And change slave's dispatchReadRequest method to handle a
correct offset from master.
Is this idea appropriate?
```
if (-1 == this.nextTransferFromWhere) {
if (0 == HAConnection.this.slaveRequestOffset) {
long masterOffset =
HAConnection.this.haService.getDefaultMessageStore().getCommitLog().getMaxOffset();
masterOffset =
masterOffset
- (masterOffset %
HAConnection.this.haService.getDefaultMessageStore().getMessageStoreConfig()
.getMapedFileSizeCommitLog());
if (masterOffset < 0) {
masterOffset = 0;
}
this.nextTransferFromWhere = masterOffset;
} else {
//changes
long maxOffset =
HAConnection.this.haService.getDefaultMessageStore().getCommitLog().getMaxOffset();
long minOffset =
HAConnection.this.haService.getDefaultMessageStore().getCommitLog().getMinOffset();
if (HAConnection.this.slaveRequestOffset>
maxOffset || HAConnection.this.slaveRequestOffset< minOffset) {
long masterOffset =
maxOffset
- (maxOffset %
HAConnection.this.haService.getDefaultMessageStore().getMessageStoreConfig()
.getMapedFileSizeCommitLog());
if (masterOffset < 0) {
masterOffset = 0;
}
this.nextTransferFromWhere = masterOffset;
}else {
this.nextTransferFromWhere =
HAConnection.this.slaveRequestOffset;
}
}
log.info("master transfer data from " +
this.nextTransferFromWhere + " to slave[" + HAConnection.this.clientAddr
+ "], and slave request " +
HAConnection.this.slaveRequestOffset);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]