LevelDB data loss possibilities

101 views
Skip to first unread message

pankaj goyal

unread,
Nov 3, 2017, 8:32:26 AM11/3/17
to leveldb
Hi,

I am using LevelDb in an android application. 

I faced a issue where some of the data got lost on one of the device. 
Here is the list of incidents which happened with me.

I  forced-stop my app as it hanged due to some issue.
I started using the app and everything was fine.
But after 5-6 hours when I launched the app again, some of the data on which I worked after forced-stop is lost. 

I am not able to explain the behavior of LevelDb in this case. Any data loss should have been happened immediately after force-stop. 

Is there any explanation of this defered loss of data ?

Is possible that app got killed during compaction and level0 or level1 file got partially saved or got corrupted ?

Please let us know any other secenerio of losing data in level db.

Thanks
Pankaj

Chris Mumford

unread,
Nov 3, 2017, 12:32:52 PM11/3/17
to leveldb
So on the next db open after the force stop the data was there, but after 5-6 hours of db use the data was then deleted? I'm unaware of a bug that would cause this. Are you using the POSIX env? If so be aware that it uses POSIX streams (fopen/fwrite/fclose) which buffer I/O data in the application heap, so unlike open/write/close data can be lost of the application is killed before the buffer can be flushed.
Message has been deleted

pankaj goyal

unread,
Nov 6, 2017, 1:59:57 AM11/6/17
to leveldb
Yes I am using the Posix env. But the AddRecord function calls EmitPhysicalRecord which calls flush so the data is flushed with each record write. 
Reply all
Reply to author
Forward
0 new messages