[ISSUE #6634] Polish the HA logs to better troubleshoot issues (#6635)

This commit is contained in:
rongtong
2023-04-24 10:11:01 +08:00
committed by GitHub
parent af6a95f4c5
commit 14ad16b0d5
2 changed files with 19 additions and 3 deletions
@@ -684,7 +684,11 @@ public class DefaultMessageStore implements MessageStore {
}
public void truncateDirtyFiles(long offsetToTruncate) {
LOGGER.info("truncate dirty files to {}", offsetToTruncate);
if (offsetToTruncate >= this.getMaxPhyOffset()) {
LOGGER.info("no need to truncate files, truncate offset is {}, max physical offset is {}", offsetToTruncate, this.getMaxPhyOffset());
return;
}
@@ -706,18 +710,24 @@ public class DefaultMessageStore implements MessageStore {
this.reputMessageService = new ConcurrentReputMessageService();
}
this.reputMessageService.setReputFromOffset(Math.min(oldReputFromOffset, offsetToTruncate));
long resetReputOffset = Math.min(oldReputFromOffset, offsetToTruncate);
LOGGER.info("oldReputFromOffset is {}, reset reput from offset to {}", oldReputFromOffset, resetReputOffset);
this.reputMessageService.setReputFromOffset(resetReputOffset);
this.reputMessageService.start();
}
@Override
public boolean truncateFiles(long offsetToTruncate) {
if (offsetToTruncate >= this.getMaxPhyOffset()) {
LOGGER.info("no need to truncate files, truncate offset is {}, max physical offset is {}", offsetToTruncate, this.getMaxPhyOffset());
return true;
}
if (!isOffsetAligned(offsetToTruncate)) {
LOGGER.error("Offset {} not align, truncate failed, need manual fix");
LOGGER.error("offset {} is not align, truncate failed, need manual fix", offsetToTruncate);
return false;
}
truncateDirtyFiles(offsetToTruncate);
@@ -448,7 +448,13 @@ public class AutoSwitchHAClient extends ServiceThread implements HAClient {
localEpochCache.initCacheFromEntries(localEpochEntries);
localEpochCache.setLastEpochEntryEndOffset(this.messageStore.getMaxPhyOffset());
LOGGER.info("master epoch entries is {}", masterEpochCache.getAllEntries());
LOGGER.info("local epoch entries is {}", localEpochEntries);
final long truncateOffset = localEpochCache.findConsistentPoint(masterEpochCache);
LOGGER.info("truncateOffset is {}", truncateOffset);
if (truncateOffset < 0) {
// If truncateOffset < 0, means we can't find a consistent point
LOGGER.error("Failed to find a consistent point between masterEpoch:{} and slaveEpoch:{}", masterEpochEntries, localEpochEntries);
@@ -496,7 +502,7 @@ public class AutoSwitchHAClient extends ServiceThread implements HAClient {
AutoSwitchHAClient.this.processPosition += headerSize + bodySize;
AutoSwitchHAClient.this.waitForRunning(1);
LOGGER.error("State not matched, masterState:{}, slaveState:{}, bodySize:{}, offset:{}, masterEpoch:{}, masterEpochStartOffset:{}, confirmOffset:{}",
masterState, AutoSwitchHAClient.this.currentState, bodySize, masterOffset, masterEpoch, masterEpochStartOffset, confirmOffset);
HAConnectionState.values()[masterState], AutoSwitchHAClient.this.currentState, bodySize, masterOffset, masterEpoch, masterEpochStartOffset, confirmOffset);
return false;
}