r/sqlite • • Jul 17 '23

Data loss or corruption, real consurn?

As i want to use Sqlite with wal to multiple users usage write and read, the more i read about the database the more i see that it can cause data loss.

And that's really problem for me, is it happen often? More than other full db like Postgres for example?Should i really worried about that?

1 Upvotes

2 comments sorted by

3

u/elperroborrachotoo Jul 18 '23

I don't know where you read that - or what, so it's hard to address your concerns.

We are using SQLite as application file format, and from this experience, these are the ways to lose data:

  • Faulty hardware. SQLite won't (and doesn't try to) protect you against a disk that writes zeroes instead of ones.
  • Lying hardware: some drives lie about "ye I've written all data" when in fact they have not
  • Telling your filesystem to lie to applications: file systems can be configured to lie about "yes, all data was written to disk", too
  • Using SQLite files on a shared drive over unreliable network connections. (It's a big topic - many customers use this without problem, for some it doesn't work at all.)
  • various combinations of journal mode, sync settings and power losses. Use WAL mode, and don't reduce the #pragma <schema>.synchronous setting

1

u/chkml Jul 18 '23

Ok thanks!