File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -631,6 +631,8 @@ func (d *diskQueue) handleReadError() {
631631
632632 // significant state change, schedule a sync on the next iteration
633633 d .needSync = true
634+
635+ d .checkTailCorruption (d .depth )
634636}
635637
636638// ioLoop provides the backend for exposing a go channel (via ReadChan())
Original file line number Diff line number Diff line change @@ -247,6 +247,23 @@ func TestDiskQueueCorruption(t *testing.T) {
247247 dq .Put (msg )
248248
249249 Equal (t , msg , <- dq .ReadChan ())
250+
251+ dq .Put (msg )
252+ dq .Put (msg )
253+ // corrupt the last file
254+ dqFn = dq .(* diskQueue ).fileName (5 )
255+ os .Truncate (dqFn , 100 )
256+
257+ Equal (t , int64 (2 ), dq .Depth ())
258+
259+ // return one message and try reading again from corrupted file
260+ <- dq .ReadChan ()
261+
262+ // give diskqueue time to handle read error
263+ time .Sleep (50 * time .Millisecond )
264+
265+ // the last log file is now considered corrupted leaving no more log messages
266+ Equal (t , int64 (0 ), dq .Depth ())
250267}
251268
252269type md struct {
You can’t perform that action at this time.
0 commit comments