Skip to content

Commit

Permalink
try fix invalid queu start if empty queue
Browse files Browse the repository at this point in the history
  • Loading branch information
absolute8511 committed Feb 22, 2019
1 parent 993db77 commit 76b9b9d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion nsqd/diskqueue_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,13 @@ func newDiskQueueWriter(name string, dataPath string, maxBytesPerFile int64,
if d.diskQueueStart.EndOffset.GreatThan(&d.diskWriteEnd.EndOffset) ||
d.diskQueueStart.Offset() > d.diskWriteEnd.Offset() {
nsqLog.LogErrorf("diskqueue(%s) queue start invalid: %v", d.name, d.diskQueueStart)
return &d, ErrNeedFixQueueStart
if d.diskWriteEnd.EndOffset.FileNum == 0 &&
d.diskWriteEnd.EndOffset.Pos == 0 {
// auto fix this case
d.diskQueueStart.EndOffset = d.diskWriteEnd.EndOffset
} else {
return &d, ErrNeedFixQueueStart
}
}
d.saveExtraMeta()
}
Expand Down

0 comments on commit 76b9b9d

Please sign in to comment.