fix log output

This commit is contained in:
dmchen 2024-07-29 08:34:01 +00:00
parent 3fe2bb2eff
commit 81a44ee6b7
1 changed files with 6 additions and 12 deletions

View File

@ -76,10 +76,8 @@ int64_t syncNodeUpdateCommitIndex(SSyncNode* ths, SyncIndex commitIndex) {
SyncIndex lastVer = ths->pLogStore->syncLogLastIndex(ths->pLogStore); SyncIndex lastVer = ths->pLogStore->syncLogLastIndex(ths->pLogStore);
commitIndex = TMAX(commitIndex, ths->commitIndex); commitIndex = TMAX(commitIndex, ths->commitIndex);
ths->commitIndex = TMIN(commitIndex, lastVer); ths->commitIndex = TMIN(commitIndex, lastVer);
if ((code = ths->pLogStore->syncLogUpdateCommitIndex(ths->pLogStore, ths->commitIndex)) != 0) { // TODO add return when error
// TODO add return when error (void)ths->pLogStore->syncLogUpdateCommitIndex(ths->pLogStore, ths->commitIndex);
sError("failed to update commit index since %s", tstrerror(code));
}
return ths->commitIndex; return ths->commitIndex;
} }
@ -87,10 +85,8 @@ int64_t syncNodeCheckCommitIndex(SSyncNode* ths, SyncIndex indexLikely) {
int32_t code = 0; int32_t code = 0;
if (indexLikely > ths->commitIndex && syncNodeAgreedUpon(ths, indexLikely)) { if (indexLikely > ths->commitIndex && syncNodeAgreedUpon(ths, indexLikely)) {
SyncIndex commitIndex = indexLikely; SyncIndex commitIndex = indexLikely;
if ((code = syncNodeUpdateCommitIndex(ths, commitIndex)) != 0) { // TODO add return when error
// TODO add return when error (void)syncNodeUpdateCommitIndex(ths, commitIndex);
sError("failed to update commit index since %s", tstrerror(code));
}
sTrace("vgId:%d, agreed upon. role:%d, term:%" PRId64 ", index:%" PRId64 "", ths->vgId, ths->state, sTrace("vgId:%d, agreed upon. role:%d, term:%" PRId64 ", index:%" PRId64 "", ths->vgId, ths->state,
raftStoreGetTerm(ths), commitIndex); raftStoreGetTerm(ths), commitIndex);
} }
@ -102,9 +98,7 @@ int64_t syncNodeUpdateAssignedCommitIndex(SSyncNode* ths, SyncIndex assignedComm
SyncIndex lastVer = ths->pLogStore->syncLogLastIndex(ths->pLogStore); SyncIndex lastVer = ths->pLogStore->syncLogLastIndex(ths->pLogStore);
assignedCommitIndex = TMAX(assignedCommitIndex, ths->assignedCommitIndex); assignedCommitIndex = TMAX(assignedCommitIndex, ths->assignedCommitIndex);
ths->assignedCommitIndex = TMIN(assignedCommitIndex, lastVer); ths->assignedCommitIndex = TMIN(assignedCommitIndex, lastVer);
if ((code = ths->pLogStore->syncLogUpdateCommitIndex(ths->pLogStore, ths->assignedCommitIndex)) != 0) { // TODO add return when error
// TODO add return when error (void)ths->pLogStore->syncLogUpdateCommitIndex(ths->pLogStore, ths->assignedCommitIndex);
sError("failed to update commit index since %s", tstrerror(code));
}
return ths->commitIndex; return ths->commitIndex;
} }