File tree 2 files changed +19
-0
lines changed 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() {
631
631
632
632
// significant state change, schedule a sync on the next iteration
633
633
d .needSync = true
634
+
635
+ d .checkTailCorruption (d .depth )
634
636
}
635
637
636
638
// 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) {
247
247
dq .Put (msg )
248
248
249
249
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 ())
250
267
}
251
268
252
269
type md struct {
You can’t perform that action at this time.
0 commit comments