Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pq: eliminate corruption by forcing version byte to be persisted
When the PQ creates a new page and allocates a memory-mapped buffer, the underlying file is zero'd out to full page capacity and the version byte is written to the buffer. If Logstash crashes or is shut down before any elements have been pushed into the queue page, we have no guarantees that the version marker has been persisted to the storage device. A subsequent attempt to load an all-zeros queue page will result in an obscure error message and failure to load: ~~~ AbstractPipelineExt - Logstash failed to create queue. org.logstash.ackedqueue.io.MmapPageIOV2$PageIOInvalidVersionException: Expected page version=2 but found version=0 ~~~ By sending `MappedByteBuffer#force()` immediately after the version has been added to the buffer, we can shrink the window in which a crash can leave the queue on disk in a corrupt state.
- Loading branch information