Before running any transaction step on the DB thread or the main thread, we check if the database is closed by calling the SQLTransaction::checkAndHandleClosedDatabase() method. Parts of that method though are intended to run only on the DB thread, and could cause a crash if run on the main thread. In particular, calling SQLTransactionCoordinator::releaseLock() on the main thread after SQLTransactionCoordinator::shutdown() was called on the DB thread triggers an assertion failure.
Solution: check what thread we're on inside SQLTransaction::checkAndHandleClosedDatabase() and only run the appropriate code for that thread.
Created attachment 49874 [details]
Comment on attachment 49874 [details]
Per our IM discussion, please describe why it's impossible to write a deterministic regression test for it and mention the flakiness in the layout test it fixes.
Landed as r55487.