Live data from Hacker News

How to corrupt an SQLite database file

sqlite.org

31–40 of 45 posts

Re: How to corrupt an SQLite database file

#31

I just finished building an open-source project using SQLite, and this makes me a little nervous. Is SQLite generally considered a reliable system? I've only had one experience with the DB becoming corrupted and that was because I used the Task Manager to force kill the process while it was running under a heavy load, and I felt that was understandable.

killing a process which is using SQLite shouldn't corrupt the database, same as pulling the plug.

Re: How to corrupt an SQLite database file

#32
post #10
post #9

Earlier quoted context omitted.

So is the official pronunciation of SQLite spelling out the letters then? I’d expect “a” not “an”…

I have never heard it pronounced in any other way than "s-q-lite".

Odd. I've never heard it pronounced in any other way than "Sequel-lite".

Re: How to corrupt an SQLite database file

#33
post #21
post #20

> One example of this occurred circa 2013-08-30 on the canonical repository for the Fossil DVCS. In that event, file descriptor 2 (standard error) was being erroneously closed (by stunnel, we suspect) prior to sqlite3_open_v2() so that the file descriptor used for the repository database file was 2. Later, an application bug caused an assert() statement to emit an error message by invoking write(2,...). But since fil…

POSIX compatibility > https://pubs.opengroup.org/onlinepubs/000095399/functions/op... > The open() function shall return a file descriptor for the named file that is the lowest file descriptor not currently open for that process.

Firstly, standards compliance is bad when the standard is bad.

Secondly nothing precludes defining '3' as the lowest file descriptor for open(), since stdin/stdout/stderr cannot be opened (they are opened before the process starts).

nb4 open("/dev/stdin"), that's not what I mean

Re: How to corrupt an SQLite database file

#34

I just finished building an open-source project using SQLite, and this makes me a little nervous. Is SQLite generally considered a reliable system? I've only had one experience with the DB becoming corrupted and that was because I used the Task Manager to force kill the process while it was running under a heavy load, and I felt that was understandable.

> Is SQLite generally considered a reliable system? It is arguably the most battle-tested piece of software on the planet. It's deployed basically on every single piece of tech out there.

And in many cases, multiple times. I wouldn't be surprised if the number of SQLite DBs on my phone was in the hundreds and the number of separately compiled copies of the library is in double digits.

Re: How to corrupt an SQLite database file

#35

I just finished building an open-source project using SQLite, and this makes me a little nervous. Is SQLite generally considered a reliable system? I've only had one experience with the DB becoming corrupted and that was because I used the Task Manager to force kill the process while it was running under a heavy load, and I felt that was understandable.

> Is SQLite generally considered a reliable system? It is arguably the most battle-tested piece of software on the planet. It's deployed basically on every single piece of tech out there.

Thanks, appreciate it!

Re: How to corrupt an SQLite database file

#36
post #7

Earlier quoted context omitted.

It’s impressive. To admit fallibility is to be honest. It represents confidence.

Also represents good test coverage

It's almost a HN meme at this point (and you might be referencing it ;-)). But for anyone unaware, SQLite's test coverage is _outstanding_ and well worth reading about[0].

[0] https://www.sqlite.org/testing.html

Re: How to corrupt an SQLite database file

#37

Interesting that it doesn't specifically call out Anti-Virus scanning (which does occasionally result in at least one of these scenarios). I've seen many SQLite database become corrupted and the best you can do is have a backup.

SQLite has code to work around anti-virus scanning, by doing retries while the anti-virus tool is processing an operation. I've not seen anti-virus tools result in corruption on the SQLite forum.

Re: How to corrupt an SQLite database file

#39
I've never corrupted an SQLite database _file_, but an FTS5 index is remarkably easy to mess up if you don't read and understand the docs to the letter and which parts of them apply to your exact use case. When you do a thing wrong with FTS5, you either get a generic ambiguous error, or silent corruption of the index. It's not a black-box extension to you can just enable with no understanding of how it works under the hood, I learned that the hard way.

Re: How to corrupt an SQLite database file

#40
post #38

Earlier quoted context omitted.

Not Sequel-lite?

Nope. A quote from Dr. Hipp: "How do I pronounce the name of the product? I say S-Q-L-ite, like a mineral."

This feels like the most ridiculous option and one I've never heard in the wild. Sequel-ite, S-Q-lite, sure. S-Q-L-ite, nah I'm not buying that. Kinda like the inventor of GIF insisting on pronouncing it wrong (I kid)
Post reply on HN