On 8 Nov 2013, at 6:41am, Mayank Kumar (mayankum) <[email protected]> wrote:
> [MK] I am using a flash drive running on linux kernel 2.6.27.10(SMP). The > corruption is sometimes seen on sqlite db on the flash drive and sometimes > seen on sqlite db in nvram. Network file system is not involved. I have used SQLite extensively on a Macintosh, storing the data on a Flash drive and pulling the drive without warning to simulate hardware and power problems. I have tested with Flash drives formatted in FAT format and other Flash drives formatted in HFS+ (A Macintosh native format.) While I have lost new transactions by doing this, unless the format structure of the drive was damaged I have not ended up with any databases which fail PRAGMA integrity_check . Note that it is important not to manually delete journal files after plugging the drive back in but before starting a SQLite app. The one problem with this is, as noted, when the format structure of the drive is damaged, i.e. the drive fails in disk/folder/file-structure checking software like chkdsk/Disk Utility. Under those situations, SQLite can attempt to rescue its database file but end up causing other problems because it is writing to corrupt workspace. Cannot be solved inside SQLite. > [MK] in my case the db is corrupted but there is also a journal file present. > When I try to write a new transaction to the corrupted db, the new > transaction is successful and at the same time the journal file gets deleted. > The resultant db is still corrupted. Can we assume from this behavior that > the corruption happened before the last failed transaction for which there is > a journal file assuming that a journal file is created per transaction. I'm not familiar enough with the inner workings of SQLite to give a definitive answer, but your description of what happens is the same as what I see and ... <http://www.sqlite.org/tempfiles.html> "The default journaling mode is DELETE, which is the default behavior of deleting the rollback journal file at the end of each transaction" which suggests that you're right if you haven't changed your journal mode. You may be able to use the PRAGMA I listed earlier to learn more about your setup. Simon. _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

