Skip to content

Commit 1ad5a8b

Browse files
fix: race condition in transaction (#91)
* fix: race condition in transaction * chore: update package version * chore: update functions to make testing easier
1 parent 5b795d1 commit 1ad5a8b

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Changelog
22

3+
## 1.0.0-BETA13
4+
5+
* Move iOS database driver to use IO dispatcher which should avoid race conditions and improve performance.
6+
37
## 1.0.0-BETA12
48

5-
* Use transaction context in `writeTransaction` in `BucketStorageImpl` to avoid race condition issues in Swift SDK.
9+
* Use transaction context in `writeTransaction` in `BucketStorageImpl`.
610

711
## 1.0.0-BETA11
812

core/src/iosMain/kotlin/com/powersync/DatabaseDriverFactory.ios.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import kotlinx.cinterop.asStableRef
1717
import kotlinx.cinterop.staticCFunction
1818
import kotlinx.cinterop.toKString
1919
import kotlinx.coroutines.CoroutineScope
20+
import kotlinx.coroutines.Dispatchers
21+
import kotlinx.coroutines.IO
2022

2123
@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
2224
@OptIn(ExperimentalForeignApi::class)
@@ -51,10 +53,13 @@ public actual class DatabaseDriverFactory {
5153
scope: CoroutineScope,
5254
dbFilename: String,
5355
): PsSqlDriver {
56+
val dbDispatcher = Dispatchers.IO
57+
val dbScope = CoroutineScope(scope.coroutineContext + dbDispatcher)
58+
5459
val schema = InternalSchema.synchronous()
5560
this.driver =
5661
PsSqlDriver(
57-
scope = scope,
62+
scope = dbScope,
5863
driver =
5964
NativeSqliteDriver(
6065
configuration =

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ development=true
1717
RELEASE_SIGNING_ENABLED=true
1818
# Library config
1919
GROUP=com.powersync
20-
LIBRARY_VERSION=1.0.0-BETA12
20+
LIBRARY_VERSION=1.0.0-BETA13
2121
GITHUB_REPO=https://github.com/powersync-ja/powersync-kotlin.git
2222
# POM
2323
POM_URL=https://github.com/powersync-ja/powersync-kotlin/

0 commit comments

Comments
 (0)