Reputation: 3464
We've had issues in the past where a rogue process was keeping a sqlite db locked. I've written some code to notify us if this is happening, but need to test it.
How can I deliberately lock up a sqlite database, so that I can check if it's locked?
Upvotes: 27
Views: 15977
Reputation: 116397
Execute these statements:
PRAGMA locking_mode = EXCLUSIVE;
BEGIN EXCLUSIVE;
This will lock whole database until you execute:
COMMIT;
// turn off exclusive locking mode
PRAGMA locking_mode = NORMAL;
// for locking mode to actually take effect, perform any read or write operation on any table:
SELECT * FROM any_table LIMIT 1;
For simplicity, you can do this using sqlite3
command line utility.
For more info, see documentation.
Upvotes: 29