Skip to content

Commit

Permalink
fix: transaction resulting in race condition when not using the corre…
Browse files Browse the repository at this point in the history
…ct context (#89)

* fix: transaction resulting in race condition when not using the correct context

* chore: add changelog and version updates
  • Loading branch information
DominicGBauer authored Dec 18, 2024
1 parent cc0a8ea commit 87cf718
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.0.0-BETA12

* Use transaction context in `writeTransaction` in `BucketStorageImpl` to avoid race condition issues in Swift SDK.

## 1.0.0-BETA11

* Update version to fix deployment issue of previous release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ internal class BucketStorageImpl(

logger.i { "[updateLocalTarget] Updating target to checkpoint $opId" }

return db.writeTransaction {
return db.writeTransaction { tx ->
if (hasCrud()) {
logger.w { "[updateLocalTarget] ps crud is not empty" }
return@writeTransaction false
}

val seqAfter =
db.getOptional("SELECT seq FROM sqlite_sequence WHERE name = '${InternalTable.CRUD}'") {
tx.getOptional("SELECT seq FROM sqlite_sequence WHERE name = '${InternalTable.CRUD}'") {
it.getLong(0)!!
}
?: // assert isNotEmpty
Expand All @@ -112,7 +112,7 @@ internal class BucketStorageImpl(
return@writeTransaction false
}

db.execute(
tx.execute(
"UPDATE ${InternalTable.BUCKETS} SET target_op = CAST(? as INTEGER) WHERE name='\$local'",
listOf(opId),
)
Expand Down

0 comments on commit 87cf718

Please sign in to comment.