nsqio / go-diskqueue

A Go package providing a filesystem-backed FIFO queue
MIT License
464 stars 103 forks source link

.bad files are created when r/w operations happen alternately until queue file is rolled #38

Open lootek opened 2 years ago

lootek commented 2 years ago

Reproduction as unit test: https://github.com/nsqio/go-diskqueue/pull/37

mreiferson commented 2 years ago

Nice find. This is broken because we check to roll the file on write at the beginning of writeOne(), so when the size of the file reaches maxBytesPerFile (exactly), it doesn't roll until the next write.