Most active commenters
  • lifthrasiir(5)

←back to thread

275 points whatisabcdefgh | 15 comments | | HN request time: 1.637s | source | bottom
1. lifthrasiir ◴[] No.45134401[source]
SQLite can't be reliably used in networked file systems because it heavily relies on locking to be correctly implemented. I recently had to add a check for such file systems in my application [1] because I noticed a related corruption firsthand. Simpler file formats do not demand such requirements. SQLite is certainly good, but not for this use.

[1] https://github.com/lifthrasiir/angel/commit/50a15e703ef2c1af...

replies(4): >>45134413 #>>45135134 #>>45135346 #>>45135619 #
2. greenavocado ◴[] No.45134413[source]
Easy fix is an empty lock file adjacent to the real one.
replies(1): >>45134419 #
3. lifthrasiir ◴[] No.45134419[source]
Yeah, but only if SQLite did support that mode in some built-in VFS implementation...
replies(1): >>45134841 #
4. hedora ◴[] No.45134841{3}[source]
Which network filesystems are still corrupting sqlite files?

Sqlite on NFSv3 has been rock solid for some NFS servers for a decade.

Maybe name and shame?

replies(1): >>45135307 #
5. afiori ◴[] No.45135134[source]
In that case the application would keep a temporary file and copy over when saving
replies(1): >>45135547 #
6. lifthrasiir ◴[] No.45135307{4}[source]
Specifically I had an issue over 9p used by WSL2. (I never thought it was networked before this incident.)
replies(1): >>45151333 #
7. chungy ◴[] No.45135346[source]
That's pretty broad and over-generalized. Networking file systems without good lock support is almost always a bad setup by an administrator. Both NFS and CIFS can work with network-wide locks just fine.

SQLite advises against using a networking file system to avoid potential issues, but you can successfully do it.

replies(2): >>45135607 #>>45136892 #
8. cpach ◴[] No.45135547[source]
Maybe, but how would the application know if /data/foo.bar is a local file or mounted via NFS/SMB/etc?
replies(1): >>45136701 #
9. jdboyd ◴[] No.45135607[source]
Are the typical Synology, Qnap, or TrueNAS devices with default Linux, macOS and Windows clients going to be set up correctly by default? If any of the typical things someone is likely to setup following wizards in a home or small office is likely to result in lock not working correctly for SQLite, then it is fair for them to warn against using it on a network file system.

As an application format, you don't generally expect people to be editing an ODF file at the same time though, so network locking doesn't really disqualify it for use as a document format.

replies(1): >>45135947 #
10. kvdveer ◴[] No.45135619[source]
In the context of this article, that's largely irrelevant: ZIP cannot be used in a multi-user scenario at all, so even if sqlite isn't perfect, it's still miles better than the ZIP format it replaces in this thought experiment.
11. mschuster91 ◴[] No.45135947{3}[source]
> As an application format, you don't generally expect people to be editing an ODF file at the same time though

Oh hell yes you do. Excel spreadsheets are notorious for people wanting to collaborate on them, and PowerPoint sheets come in close second. It used to be an absolute PITA but at least Office 365 makes the pains bearable.

12. afiori ◴[] No.45136701{3}[source]
it would always use such a temporary file and update the "real" file only on explicit saves with fast mv or cp operations
13. lifthrasiir ◴[] No.45136892[source]
As noted in my other comment, those "potential" issues are real and do happen from time to time. Unless SQLite gives some set of configurations to avoid such issues, I can't agree that it's over-generalized.
14. hedora ◴[] No.45151333{5}[source]
It seems odd to break a wide range of valid configs for something so obscure.
replies(1): >>45155150 #
15. lifthrasiir ◴[] No.45155150{6}[source]
Yes, that was surprising to me too! I was able to fairly reliably reproduce data corruption in this case.