fix: write ahead buffer unittest failure (#45978)

issue: #45977

Signed-off-by: chyezh <chyezh@outlook.com>
This commit is contained in:
Zhen Ye 2025-12-02 10:25:10 +08:00 committed by GitHub
parent f62297db92
commit 10a781d22c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -98,6 +98,7 @@ func (w *WriteAheadBuffer) ReadFromExclusiveTimeTick(ctx context.Context, timeti
}
return &WriteAheadBufferReader{
nextOffset: nextOffset,
lastTimeTick: timetick,
snapshot: snapshot,
underlyingBuf: w,
}, nil

View File

@ -104,6 +104,9 @@ func TestWriteAheadBuffer(t *testing.T) {
}
}
}()
if rand.Int31n(2) == 0 {
time.Sleep(20 * time.Millisecond)
}
r1, err := wb.ReadFromExclusiveTimeTick(context.Background(), 1)
assert.NoError(t, err)
assert.NotNil(t, r1)
@ -130,7 +133,7 @@ func TestWriteAheadBuffer(t *testing.T) {
// Read from half of the timetick
<-ch
assert.Equal(t, totalCnt, len(timeticks))
assert.Equal(t, totalCnt, len(timeticks)+1)
targetTimeTickIdx := len(timeticks) / 2
for targetTimeTickIdx < len(timeticks) && timeticks[targetTimeTickIdx+1] == timeticks[targetTimeTickIdx] {