Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(shared): let SQLite reads proceed beside slow reads #24762

Closedjuliusmarmingewants to merge 3 commits intomain fromfix/issue-24660opened View on GitHub

Showing 2 changed files with 26 additions and 0 deletions (loading 1).

x
0 of 2 viewed, 2 left
26 additions and 0 deletionspackages/shared/src/nodeSqliteClient.test.tsModified
View file
@@ -238,6 +238,32 @@
​
+// regression: #24660 one read-only transaction must not hold every other read behind it
+it.effect("runs an unrelated read while a read-only transaction holds a reader", () =>
+ withReaderClient((sql) =>
+ Effect.gen(function* () {
+ const held = yield* Deferred.make<void>();
+ const release = yield* Deferred.make<void>();
+ const holder = yield* sql
+ .withTransaction(
+ countEntries(sql).pipe(
+ Effect.andThen(Deferred.succeed(held, undefined)),
+ Effect.andThen(Deferred.await(release)),
+ ),
+ )
+ .pipe(SqliteClient.readOnly, Effect.forkChild);
+ yield* Deferred.await(held);
+​
+ // The holder ends only after this read, so a single reader permit deadlocks here.
+ const count = yield* countEntries(sql).pipe(SqliteClient.readOnly);
+ yield* Deferred.succeed(release, undefined);
+ yield* Fiber.join(holder);
+​
+ assert.equal(count, 1);
+ }),
+ ),
+);
+​