Page MenuHomePhabricator

sqlitestore: create new connections on new PIDs

Authored by indygreg on Dec 11 2018, 7:00 PM.


Group Reviewers

If the Mercurial process fork()s, the Python thread ID remains
unchanged. The previous code for returning a SQLite connection would
recycle the existing connection among all children.

Mercurial can fork() when performing working directory updates.
For reasons I don't fully understand, the recycling of even a
read-only SQLite connection was resulting in Python raising a
"DatabaseError: database disk image is malformed" exception. This
message comes from the bowels of SQLite. I suspect there is some
internal client state in the SQLite database somewhere and having
multiple clients race to update it results in badness. Who knows.

This commit teaches the "get a SQLite connection" logic to also
verify the PID matches before returning an existing connection.

Diff Detail

rHG Mercurial
Lint Skipped
Unit Tests Skipped

Event Timeline

indygreg created this revision.Dec 11 2018, 7:00 PM
indygreg planned changes to this revision.Dec 11 2018, 7:10 PM

Hold off on reviewing this. I'm still debugging some issues at Mozilla and want to be sure this patch is correct...

indygreg abandoned this revision.Dec 11 2018, 8:55 PM

It turns out we were hitting a bug in an ancient version of SQLite. Upgrading from 3.11 to 3.22 fixed it. I don't think this patch is needed.