3 ms·
AFAIK SQLite has weird locks, half year ago they weren't fair and writers could get timeout easily. For workaround we implemented external lock and it have been
by bvrmn 3y ago
AFAIK SQLite has weird locks, half year ago they weren't fair and writers could
get timeout easily. For workaround we implemented external lock and it have been worked quite smoothly since.
SQLite's locking code looks like:
while lock_is_still_held_by_somebody():
sleep(3) # 3 seconds
- ilyt 3y agoDid you use WAL? But in general, funelling writes into one thread is the way to get around it
- bvrmn 3y agoYes. It's doesn't matter wal or default behavior.
- hajile 3y agoShouldn’t there be a random jitter added?
- bvrmn 3y agoIt's SQLite's locking implementation. In real code it includes some backoff but on long timeouts it reaches 3s. Jitter doesn't help BTW it's still unfair. On high contention each worker only has a slim chance to get a lock.