Skip to content

Commit

Permalink
[Enhancement] Log the content of journal entity on replay failure (ba…
Browse files Browse the repository at this point in the history
…ckport #46011) (#46028)

Signed-off-by: yiming <[email protected]>
Co-authored-by: yiming <[email protected]>
  • Loading branch information
mergify[bot] and nshangyiming authored May 23, 2024
1 parent 3effd9e commit dddc16f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void close() throws IOException, SRMetaBlockException {
LOG.warn("Meta block for {} read {} json < total {} json, will skip the rest {} json",
header.getSrMetaBlockID(), numJsonRead, header.getNumJson(), rest);
for (int i = 0; i != rest; ++i) {
LOG.warn("skip {} json: {}", i, Text.readStringWithChecksum(checkedInputStream));
LOG.warn("skip {}th json: {}", i, Text.readStringWithChecksum(checkedInputStream));
}
}

Expand Down
22 changes: 17 additions & 5 deletions fe/fe-core/src/main/java/com/starrocks/server/GlobalStateMgr.java
Original file line number Diff line number Diff line change
Expand Up @@ -2199,17 +2199,16 @@ protected boolean replayJournalInner(JournalCursor cursor, boolean flowControl)
EditLog.loadJournal(this, entity);
} catch (Throwable e) {
if (canSkipBadReplayedJournal()) {
LOG.error("!!! DANGER: SKIP JOURNAL {}: {} !!!",
replayedJournalId.incrementAndGet(),
entity == null ? null : entity.getData(),
e);
LOG.error("!!! DANGER: SKIP JOURNAL, id: {}, data: {} !!!",
replayedJournalId.incrementAndGet(), journalEntityToReadableString(entity), e);
if (!readSucc) {
cursor.skipNext();
}
continue;
}
// handled in outer loop
LOG.warn("catch exception when replaying {},", replayedJournalId.get() + 1, e);
LOG.warn("catch exception when replaying journal, id: {}, data: {},",
replayedJournalId.get() + 1, journalEntityToReadableString(entity), e);
throw e;
}

Expand Down Expand Up @@ -2247,6 +2246,19 @@ protected boolean replayJournalInner(JournalCursor cursor, boolean flowControl)
return false;
}

private String journalEntityToReadableString(JournalEntity entity) {
if (entity == null) {
return null;
}
Writable data = entity.getData();
try {
return GsonUtils.GSON.toJson(data);
} catch (Exception e) {
// In older version, data may not be json, here we just return the binary data.
return data.toString();
}
}

private boolean canSkipBadReplayedJournal() {
try {
for (String idStr : Config.metadata_journal_skip_bad_journal_ids.split(",")) {
Expand Down

0 comments on commit dddc16f

Please sign in to comment.