Writing to SQLite dataset when other processes are

2019-03-06 06:22发布

Reading the SQLite documentation here, when a process wants to write to a SQLite database it obtains a reserved lock. Then once the process is ready to write to disk it obtains a pending lock, during which no new processes can obtain a shared lock, but existing shared locks are allowed to finish their business. Once the remaining shared locks clear, the process can write.

However...when I try to write a database while other processes are reading from that database, I just get an immediate "Error: dataset is locked".

sqlite> insert into meta_models (model) values ("hello_world");
Error: database is locked

Why doesn't SQLite it go through the steps I outlined above of waiting for the shared locks to clear?

1条回答
Evening l夕情丶
2楼-- · 2019-03-06 06:46

SQLite does go through these steps, but it timed out while waiting for the remaining shared locks to clear.

You can adjust this timeout with PRAGMA busy_timeout.

查看更多
登录 后发表回答