mirror of
https://github.com/apache/rocketmq.git
synced 2026-08-28 20:09:14 +08:00
[ISSUE #9689] Fix the issue that master transfer epoch was not updated in time
This commit is contained in:
@@ -21,9 +21,10 @@ import java.util.Objects;
|
||||
|
||||
public class EpochEntry extends RemotingSerializable {
|
||||
|
||||
public static final long LAST_EPOCH_END_OFFSET = Long.MAX_VALUE;
|
||||
private int epoch;
|
||||
private long startOffset;
|
||||
private long endOffset = Long.MAX_VALUE;
|
||||
private long endOffset = LAST_EPOCH_END_OFFSET;
|
||||
|
||||
public EpochEntry(EpochEntry entry) {
|
||||
this.epoch = entry.getEpoch();
|
||||
|
||||
+14
@@ -593,6 +593,20 @@ public class AutoSwitchHAConnection implements HAConnection {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check and update currentTransferEpochEndOffset
|
||||
if (AutoSwitchHAConnection.this.currentTransferEpochEndOffset == -1) {
|
||||
EpochEntry currentEpochEntry = AutoSwitchHAConnection.this.epochCache.getEntry(AutoSwitchHAConnection.this.currentTransferEpoch);
|
||||
if (currentEpochEntry != null) {
|
||||
if (currentEpochEntry.getEndOffset() != EpochEntry.LAST_EPOCH_END_OFFSET) {
|
||||
LOGGER.info("Update currentTransferEpochEndOffset from -1 to {}", currentEpochEntry.getEndOffset());
|
||||
AutoSwitchHAConnection.this.currentTransferEpochEndOffset = currentEpochEntry.getEndOffset();
|
||||
}
|
||||
} else {
|
||||
// we should never reach here
|
||||
LOGGER.warn("[BUG]Can't find currentTransferEpoch [{}] from epoch cache", currentTransferEpoch);
|
||||
}
|
||||
}
|
||||
|
||||
// We must ensure that the transmitted logs are within the same epoch
|
||||
// If currentEpochEndOffset == -1, means that currentTransferEpoch = last epoch, so the endOffset = Long.max
|
||||
final long currentEpochEndOffset = AutoSwitchHAConnection.this.currentTransferEpochEndOffset;
|
||||
|
||||
Reference in New Issue
Block a user