fix: call truncate when checkpoint is persisted (#46382)

issue: #44434

Signed-off-by: tinswzy <zhenyuan.wei@zilliz.com>
This commit is contained in:
tinswzy 2025-12-21 19:01:17 +08:00 committed by GitHub
parent bfc33130be
commit 9345caa135
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -143,9 +143,23 @@ func (rs *recoveryStorageImpl) persistDirtySnapshot(ctx context.Context, lvl zap
// sample the checkpoint for truncator to make wal truncation.
rs.metrics.ObServePersistedMetrics(snapshot.Checkpoint.TimeTick)
rs.simpleTruncateCheckpoint(ctx, snapshot.Checkpoint)
return
}
func (rs *recoveryStorageImpl) simpleTruncateCheckpoint(ctx context.Context, checkpoint *WALCheckpoint) {
flusherCP := rs.getFlusherCheckpoint()
if flusherCP == nil {
return
}
// use the smaller one to truncate the wal.
if flusherCP.MessageID.LTE(checkpoint.MessageID) {
_ = rs.truncator.Truncate(ctx, flusherCP.MessageID)
} else {
_ = rs.truncator.Truncate(ctx, checkpoint.MessageID)
}
}
// dropAllVirtualChannel drops all virtual channels that are in the dropped state.
// TODO: DropVirtualChannel will be called twice here,
// call it in recovery storage is used to promise the drop virtual channel must be called after recovery.