LiveServerTestCase + in-memory SQLite do not work together
|Reported by:||anonymous||Owned by:||nobody|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
When running LiveServerTestCase with in-memory SQLite database (no NAME in settings) the liveserver and the test case share the connections. The static files serving done to by liveserver will cause concurrent requests while the test is running, and these concurrent requests will cause close_connection to be called (and also will cause session checking by cookies, and thus concurrent queries).
The browser is free to ask some static files even after the real request has finished. Such files might be images for example.
This causes two issues:
- the newly introduced close_connection -> transaction.abort() call will cause constant spamming of transaction.rollback while the test case is running. This will cause random failures.
- even if close_connection isn't called, there will be concurrent queries by two different threads, and at least some versions of sqlite do not like this at all (segfaults are possible).
Unfortunately this affects the just released 1.4.4. This only happens when running liveserver tests with in-memory SQLite DB. The workaround is to use file based SQLite when testing.
Change History (9)
comment:1 Changed 4 years ago by
|Patch needs improvement:||unset|
|Triage Stage:||Unreviewed → Accepted|