fbnzk / leveldb

Automatically exported from code.google.com/p/leveldb
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Corrupted manifest data at mmap rollover #155

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm not sure how exactly this happened, but I have a corrupted manifest file in 
which the (partial) record just before the 983040-byte mark is filled with 
zeros.  The file was written to successfully after this; the entire file is 
1081344 bytes long.  The database worked normally for the lifetime of the 
process that this happened in, but now opening it results in an error 
"Corruption: missing start of fragmented record(2)".  

983040 bytes is one of the points where PosixMmapFile unmaps the old region and 
maps a new one, so it is possible that the fault lies in the way the data is 
unmapped (and written to disk with fsync/fdatasync instead of msync).  

This may be related to the bug fixed in version 1.9: Errors from Sync() are now 
ignored as long as the record is readable in the file (which may be reading 
from memory rather than disk).  Sync failures may not be recoverable in general 
(the device on which this occurred has a history of unexplained crashes and so 
may just have flaky hardware), but in the event of a sync failure it may be 
better to close the manifest and reopen a new file with a fresh snapshot (and 
then if that cannot be done to fail the write and mark the database as 
unusable).

What version of the product are you using? On what operating system?

LevelDB 1.9 on iOS 6.  

Original issue reported on code.google.com by ben.darn...@gmail.com on 29 Mar 2013 at 5:41