Comments (6)
fun foo() = runBlocking {
async(Dispatchers.IO) {
queries.transactionWithResult {
//Nothing
}
}
async(Dispatchers.IO) {
queries.transactionWithResult {
//Nothing
}
}
}
Just open 2 transactions in async and the driver raise this error.
It's like the driver try to run the transactions in a same thread and open a new transaction inside the first one.
Same with threads, just start 2 transactions in 2 threads, and the driver run the second transaction in the first one.
thread {
queries.transactionWithResult { }
}
thread {
queries.transactionWithResult { }
}
Thread.sleep(500)
Exception in thread "Thread-6" org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (cannot start a transaction within a transaction)
In SQLDelight 2.0.0, to prevent this issue, I used a custom Dispatcher for my database request, limited to one parallelism.
val databaseDispatcher = Dispatchers.IO.limitedParallelism(1)
val table1Data = async(databaseDispatcher) { ... }
val table2Data = async(databaseDispatcher) { ... }
But, of course, I break the parallelism of async in this temporary solution. And only one request can run at the same time.
I will return easily to the Dispatcher.IO when the fix will be done.
from sqldelight.
I'm not sure how this would result in nested transactions, is the method you're calling this from itself in a transaction?
Although SQLDelight does some protection from inner transactions (with the noEnclosing stuff) so that also surprised me. Are you able to make a repro project we can look in to?
from sqldelight.
Setting up a repro project would be a lot of work. If I have the free time, I can try to create one. No, the method itself is not in a transaction. This issue is reproduced in roughly 5% calls run
from sqldelight.
True, I am also still seeing this happening often still. Thanks, didn't expect the repro to be that simple
from sqldelight.
@AlecKazakova may I request this issue to be triaged? There is no more info to add and this issue currently affects a very large portion of our users in production
This issue alone has brought our project below the GP bad behavior threshold already
from sqldelight.
It could be also a platform bug, but maybe triggered by SqlDelight. We have seen a similar bug in Room too.
Here is a link to the "platform bug":
https://issuetracker.google.com/issues/37001653
from sqldelight.
Related Issues (20)
- Hide inlay hints if named arguments are used and name matches column
- java.lang.AssertionError in AddImportIntention.kt:109
- Overloaded functions generate the same identifier
- java.lang.RuntimeException in FileIndexMap.kt:101
- com.intellij.serviceContainer.AlreadyDisposedException in ProjectService.kt:174
- com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments in UnusedImportInspection.kt:57
- Add a SchemaProvider to fetch an existing schema of a remote database
- kfun:app.cash.sqldelight.driver.native.NativeSqliteDriver#notifyListeners(kotlin.Array<out|kotlin.String>...){} + 728 HOT 1
- java.lang.AssertionError in SqliteParserUtil.kt:70
- Database db file doesn't seem to be being created; crash with no such table
- `OutOfMemoryError` when building project HOT 2
- sqldelight gradle plugin breaks usage of kotlinx.coroutines HOT 2
- `JdbcSqliteDriver.IN_MEMORY` nomenclature is incorrect
- java.lang.Throwable in ProjectService.kt:215
- Provide default web worker for sqlite wasm HOT 1
- Fix web worker karma config HOT 2
- java.lang.Throwable in Logger.java:376
- Better support for JS/Wasm-only projects that use Multiplatform plugin
- org.jetbrains.kotlin.idea.caches.resolve.KotlinIdeaResolutionException in SqlDelightGotoDeclarationHandler.kt:124
- kotlin.NotImplementedError in ProjectService.kt:176
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqldelight.