-
Notifications
You must be signed in to change notification settings - Fork 160
StressAsync fails #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
How do we get the stress test to pass? Is this a bug with sqlite3 in Windows? |
This test has been buggy for a long time, I've tried to fix it but I have not yet been able to. |
When I debug in VS I keep running into 'busy' and 'database locked'. In In an earlier discussion on Generic and Mac, someone mentioned that their On Wed, Nov 11, 2015 at 2:31 PM, Øystein Krog [email protected]
|
Since this test is running a large number of concurrent operations I would suggest two changes:
These two changes may resolve the errors you are seeing. |
Good suggestions, thanks! On Thu, Nov 12, 2015 at 6:29 AM, Stephen Lombardo [email protected]
|
@sjlombardo I tried your suggestion. Interestingly, journal_mode = delete (default) and journal_mode = wal have characteristically different errors. Here are the errors for delete and wal for a sample for busy timeout of 100. I changed the test to 100 items because 500 was taking too long. wal is better than delete, but increasing the timeout for wal does not seem to improve it. (Not sure why not, since it is busy).
and
|
I just discovered that the busy_timeout is reset in new connections. I probably have to set it longer for each of the threads. That is a little scary. |
Sadly, even setting busy_timeout for each of the runs did not change the Busy error. I changed it from 100 to 1000 with no real change in Busy errors, which is about 33%. |
http://beets.radbox.org/blog/sqlite-nightmare.html was interesting, i wonder if we are facing that in the test |
The Busy signal always comes in INSERT rather than when it is selecting from the table. |
I was able to make progress by adding this to PreparedSqlLiteInsertCommand
Now there are no Busy errors, but the final count is 94 instead of 100. Locked using
But does this mean we need this everywhere? Isn't SQLite supposed to handle this. :P |
Ok, with the locker code in place, the new error is that there are only 94 / 100 when the count is asked for. However, if you Task.Delay(1000) before reading the count, everything is actually in there. This means the Task completes before the task is really completed. Not sure how that is possible, but maybe each connection has a separate cache of some sort.
I experimented with some values and 100-200 usually works. Maybe we should be using the same connection instead of opening a lot of new ones? I don't know. |
Once I enter 'wal' I can't back out of it at the end of the test.
at the end gives me 'database is locked' ;( |
Why is
needed when it should already be locked by SQLiteConnectionWithLock Actually, and this is bad because the _locker is static so it would prevent writing to different databases |
If I change the task connection to the global connection, it does not negate the need for the Task.Delay - it feels like the WhenAll is not really waiting for all the tasks to complete. |
Sorry for this long thread - I wonder if anyone will ever read it. await Task.WhenAll(tasks) does not really do what we think it does... check this out. It says 100 tasks are completed (end of the WhenAll) but there are actually 6 more going.
|
It turns out that Task.Factory.StartNew does not work well with Task.WhenAll. We should be using Task.Run. When this is done, voila, no need for a Delay.
|
"As commented by Svick, Task.Factory.StartNew has different overloads and functionality to that of Task.Run these differences have been blogged about here: Task.Run vs Task.Factory.StartNew. The result of Task.Factory.StartNew(async () => ... is a Task, so when calling Task.WhenAll you are only waiting for the outer Task to complete." |
I get about 400 errors in NCrunch (from sqlite being 'busy') and 17-18 in appveyor
The text was updated successfully, but these errors were encountered: