Skip to content

Commit 426df23

Browse files
committed
fix race condition
1 parent 5945758 commit 426df23

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

db/db.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,11 @@ func (l *Loader) HasTable(tableName string) bool {
454454
}
455455

456456
// GetActiveFlushesNum returns the current number of in-flight async flushes.
457-
// This value is approximate and may be racy; it is intended for metrics only.
458-
func (l *Loader) GetActiveFlushesNum() int { return l.activeFlushes }
457+
func (l *Loader) GetActiveFlushesNum() int {
458+
l.cond.L.Lock()
459+
defer l.cond.L.Unlock()
460+
return l.activeFlushes
461+
}
459462

460463
func (l *Loader) MarshalLogObject(encoder zapcore.ObjectEncoder) error {
461464
encoder.AddUint64("entries_count", l.entriesCount)

0 commit comments

Comments
 (0)