[enhancement](fe) Add more detail log for replayJournal (#24218)

This commit is contained in:
Lei Zhang
2023-09-14 11:45:48 +08:00
committed by GitHub
parent 4eccf72bdd
commit adde012de0
3 changed files with 20 additions and 0 deletions

View File

@ -2612,6 +2612,7 @@ public class Env {
long startTime = System.currentTimeMillis();
boolean hasLog = false;
while (true) {
long entityStartTime = System.currentTimeMillis();
Pair<Long, JournalEntity> kv = cursor.next();
if (kv == null) {
break;
@ -2623,6 +2624,7 @@ public class Env {
}
hasLog = true;
EditLog.loadJournal(this, logId, entity);
long loadJournalEndTime = System.currentTimeMillis();
replayedJournalId.incrementAndGet();
LOG.debug("journal {} replayed.", replayedJournalId);
if (feType != FrontendNodeType.MASTER) {
@ -2632,6 +2634,14 @@ public class Env {
// Metric repo may not init after this replay thread start
MetricRepo.COUNTER_EDIT_LOG_READ.increase(1L);
}
long entityCost = System.currentTimeMillis() - entityStartTime;
if (entityCost >= 1000) {
long loadJournalCost = loadJournalEndTime - entityStartTime;
LOG.warn("entityCost:{} loadJournalCost:{} logId:{} replayedJournalId:{} code:{} size:{}",
entityCost, loadJournalCost, logId, replayedJournalId, entity.getOpCode(),
entity.getDataSize());
}
}
long cost = System.currentTimeMillis() - startTime;
if (cost >= 1000) {

View File

@ -143,6 +143,7 @@ public class JournalEntity implements Writable {
private short opCode;
private Writable data;
private long dataSize;
public short getOpCode() {
return this.opCode;
@ -164,6 +165,14 @@ public class JournalEntity implements Writable {
return " opCode=" + opCode + " " + data;
}
public void setDataSize(long dataSize) {
this.dataSize = dataSize;
}
public long getDataSize() {
return this.dataSize;
}
@Override
public void write(DataOutput out) throws IOException {
out.writeShort(opCode);

View File

@ -113,6 +113,7 @@ public class BDBJournalCursor implements JournalCursor {
JournalEntity entity = new JournalEntity();
try {
entity.readFields(in);
entity.setDataSize(retData.length);
} catch (Exception e) {
LOG.error("fail to read journal entity key={}, will exit", currentKey, e);
System.exit(-1);