-
Notifications
You must be signed in to change notification settings - Fork 355
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
Option to run a few queries sequentially #3032
Comments
I think you'd still have the problem with sequential databases because they only serialize database access at a fairly low layer. So if you do something like this Dart: await customStatement('pragma foreign_keys = OFF;');
await transaction(() async {
// ...
});
await customStatement('pragma foreign_keys = ON;'); If another async context is accessing the database and does its own thing, queries from there could be interleaved between the I agree that having a block that reliably locks the database is a good addition. It should ideally be implemented at a |
@simolus3 I was thinking at the BaseExecutor level, which already manages its own lock. Is that the database low level you were referring to or the QueryExecutor level? If the additional method is added to the QueryExecutor and to the DatabaseConnectionUser classes, what is the breaking change? Is it because subclasses need to implement it? |
No you're right! I've misremembered things and thought |
Currently the
DelegatedDatabase
has the notion ofisSequential
in order to support parallel queries and transactions.On ElectricSQL they recently introduced the option to disable the foreign key checks when replicating from remote, as it has better performance on web.
In order to do that it's necessary to do that in a safe manner, they do the following in a mutex. This is because foreign_keys cannot be called during a transaction.
Given that Drift can already work with sequential databases we were wondering if it would be feasible to add a function that runs a callback inside the same
synchronized
Lock. Something likerunSequentially
orrunExclusively
.Context:
electric-sql/electric#1281
https://github.com/electric-sql/electric/blob/64a01949376536492fbc72fe6bf0d8539a3552b0/clients/typescript/src/util/transactions.ts#L23
The text was updated successfully, but these errors were encountered: