Open ccjernigan opened 3 years ago
I've been continuing to hit this intermittently, and the difference between implicit and explicit database references for query/insert/delete transactions might not matter as much as I thought initially. This is the challenge with race conditions.
My current theory is that being explicit for the transaction to create the tables might help. E.g. transaction(database) { SchemaUtils.createMissingTablesAndColumns(...) }
.
Can you try the workaround
from https://github.com/JetBrains/Exposed/issues/726#issuecomment-932202379 ?
STEPS TO REPRODUCE
Create a transaction with an explicit reference to the database
where
RESULTS
Actual
With a high probability, an exception is thrown that the "subject" table does not exist.
Expected
No exception is thrown, because the table clearly exists.
NOTES
This is not 100% reproducible, as it might be a race condition. There seems to be a difference between implicit and explicit database references for transaction, where implicit references seem not to hit the issue. E.g.
transaction {}
versustransaction(database) {}
.It also seems less likely to occur if I use a file-based database, which might indicate that Hikari plays a role in this although this is not yet clear. (I'm only using Hikari as a workaround for #726.)
I'm only encountering this in my tests, not at runtime with my application. This might also be because my tests are setting up and tearing down databases several hundred times across a number of different tests, which could increase the probability of hitting race conditions.