mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-06 17:18:35 +08:00
fix: Lock before reading flusher cp sampling truncate cp (#42019)
Related to #42018 --------- Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
parent
c9b0748ff9
commit
244aa30076
@ -128,12 +128,13 @@ func (rs *recoveryStorageImpl) persistDirtySnapshot(ctx context.Context, snapsho
|
||||
}
|
||||
|
||||
func (rs *recoveryStorageImpl) sampleTruncateCheckpoint(checkpoint *WALCheckpoint) {
|
||||
if rs.flusherCheckpoint == nil {
|
||||
flusherCP := rs.getFlusherCheckpoint()
|
||||
if flusherCP == nil {
|
||||
return
|
||||
}
|
||||
// use the smaller one to truncate the wal.
|
||||
if rs.flusherCheckpoint.MessageID.LTE(checkpoint.MessageID) {
|
||||
rs.truncator.SampleCheckpoint(rs.flusherCheckpoint)
|
||||
if flusherCP.MessageID.LTE(checkpoint.MessageID) {
|
||||
rs.truncator.SampleCheckpoint(flusherCP)
|
||||
} else {
|
||||
rs.truncator.SampleCheckpoint(checkpoint)
|
||||
}
|
||||
|
||||
@ -408,3 +408,11 @@ func (r *recoveryStorageImpl) detectInconsistency(msg message.ImmutableMessage,
|
||||
r.Logger().Warn("inconsistency detected", fields...)
|
||||
r.metrics.ObserveInconsitentEvent()
|
||||
}
|
||||
|
||||
// getFlusherCheckpoint returns flusher checkpoint concurrent-safe
|
||||
// NOTE: shall not be called with r.mu.Lock()!
|
||||
func (r *recoveryStorageImpl) getFlusherCheckpoint() *WALCheckpoint {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
return r.flusherCheckpoint
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user