Hello,

I am a developer of a C# app used within the company.
The C# app uses SharpSVN 1.14005.390, which - as you may know - is a C# wrapper 
around a C++ core that makes calls to the local SVN dlls.

Our C# app is written such that the following operations can end up happening 
concurrently:

svn commit <root dir>
svn status <root dir> with depth=empty, remote=true, all=true, externals=true 
(used to determine the current remote revision)
svn status <root dir> with depth=infinity, remote=false, all=false, 
externals=true (essentially getting every node that's not "normal" about the 
working copy)
svn status <root dir> with depth=infinity, remote=true, all=false, 
externals=true (getting everything not "normal" about the server, used to 
gather information on currently locked files)

This (these commands running concurrently) has been the case for several months 
if not years at this time.
But recently, since about a week ago, we have heard multiple complaints from 
various people using the tool as they always have, that when trying to commit, 
to different repositories across multiple SVN servers, the commits fail with 
error "sqlite[S5]: database is locked" (error code SVN_ERR_SQLITE_BUSY).

I didn't find a lot about what causes this SQLite problem with regards to SVN, 
but what I found elsewhere was this article: What to do about SQLITE_BUSY 
errors despite setting a timeout - Bert Hubert's 
writings<https://berthub.eu/articles/posts/a-brief-post-on-sqlite3-database-locked-despite-timeout/>
That article says this error is triggered when SQLite doesn't manage to start a 
transaction within a defined timeout (section "SQLite transactions"). But more 
importantly, it is triggered immediately when SQLite attempts to upgrade a 
read-only transaction to a read-write transaction, and fails to do so because 
another write transaction is already open (section "Getting into trouble").

I noticed from the logs in our app that the timing when this error appeared 
during the commit attempts wasn't deterministic; sometimes it occurred before 
the 10% beacon log entry, sometimes after the 60% entry, although it was the 
same changes committed by the same person just minutes after the previous 
attempt.

This problem (SQLite error 5 during commit) was also reproducible on my machine 
with their working copy, and what every occurrence had in common was that a 
different thread was concurrently running SharpSVN's "GetStatus" when the 
commit operation threw the SvnException that wrapped the SQLite error. And sure 
enough - when I modified the tool's code to temporarily halt the C# background 
service loops which trigger said "GetStatus" commands, the commit went through 
without problems, first try.

What puzzles me is that the behavior of these commands happening concurrently 
in our tool has been there for years, and the only thing that has changed 
somewhat recently is that TortoiseSVN 1.15 was rolled out at our company on Nov 
5th, and thus with it SVN 1.15. It seems unlikely that this is not a 
regression, since we haven't seen this problem before one week ago, and have 
seen it multiple times since, but not very frequently compared to the thousands 
of commits since the 1.15 rollout. It seems like a race condition that was 
never happening before and is now very likely to happen if circumstances are 
right (e.g. large commit or large file in commit, paired with slow network due 
to VPN).

I'm writing to you because for the moment, the upgrade to SVN 1.15 is the only 
piece of evidence I have on what might have changed recently that causes 
multiple users to run into this problem now but not in all the months and years 
before. Maybe some code starts an SQLite transaction, and pre-1.15 a 
write-operation was the first command (meaning the transaction was started at 
that point as read-write, with timeout), but now someone inserted a 
read-operation before, which seems like a harmless change, but means that now 
the transaction is created as read-only, and then upgraded when the write 
command happens, which then fails immediately if you're unlucky (see section 
"Getting into trouble").

Can someone look into this please?

Thank you and kind regards
Christoph Engels

Reply via email to