Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions diskqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,8 @@ func (d *diskQueue) handleReadError() {

// significant state change, schedule a sync on the next iteration
d.needSync = true

d.checkTailCorruption(d.depth)
}

// ioLoop provides the backend for exposing a go channel (via ReadChan())
Expand Down
17 changes: 17 additions & 0 deletions diskqueue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,23 @@ func TestDiskQueueCorruption(t *testing.T) {
dq.Put(msg)

Equal(t, msg, <-dq.ReadChan())

dq.Put(msg)
dq.Put(msg)
// corrupt the last file
dqFn = dq.(*diskQueue).fileName(5)
os.Truncate(dqFn, 100)

Equal(t, int64(2), dq.Depth())

// return one message and try reading again from corrupted file
<-dq.ReadChan()

// give diskqueue time to handle read error
time.Sleep(50 * time.Millisecond)

// the last log file is now considered corrupted leaving no more log messages
Equal(t, int64(0), dq.Depth())
}

type md struct {
Expand Down