You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
using a db transaction when scanning (external) files with sqlite causes database locked errors #11391
I assume the database transaction used to commit updates of the file scanning process in batches causes an sqlite database to lock for extended periods of time, leading to the database locked error when another request comes in. With preview generation, background jobs, hooks, search lucene and maybe sync clients coming along that is very likely to happen. The chance that a lock is in place increases with the latency of file scans, meaning scanning a remote files_external storage, such as amazon s3 is highly likely to produce the db lock.
for reference, a little history:
16 Jan 2013 @icewind1991 adding a transaction to improve scan performance 6871a15
With 644755d has added a flag to the scanner that we could use to do without transactions on sqlite. AFAICT atomicity is not the reason for the transaction. Opinions @DeepDiver1975@karlitschek @schiesbn @icewind1991
Activity
craigpg commentedon Oct 2, 2014
@butonic, is this sqlite only?
butonic commentedon Oct 2, 2014
@craigpg yes, sqlite only
icewind1991 commentedon Oct 2, 2014
Disabling transitions in the scanner would be a solution but it would cause a massive performance panelty
karlitschek commentedon Oct 2, 2014
@icewind1991 Why does the transaction improve the performance? I´m not sure I understand the reason by reading the code.
butonic commentedon Oct 6, 2014
Without the transaction scanning 10000 files makes 10000 individual updates, auto committing them. Which in turn causes the affected indexes to be updated - which is slow on all DBMS, but especially on sqlite and lower end hardware. (more details on sqlite insert performance in http://stackoverflow.com/questions/1711631/how-do-i-improve-insert-per-second-performance-of-sqlite)
9 remaining items
dragotin commentedon Feb 18, 2015
Pull request that adds some closeCursors: #14329
MorrisJobke commentedon Nov 25, 2015
@PVince81 @icewind1991 Isn't this solved by high level file locking that was enabled in 8.2+?
PVince81 commentedon Nov 25, 2015
Such issues haven't been reported since a while, so it might be solved by locking, yes.
Also we did add many closeCursor calls.
MorrisJobke commentedon Nov 25, 2015
Okay let's close this here and maybe reopen if this appears again.
lock commentedon Aug 7, 2019
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.