Sqlite: tell that the current request already holds a transaction on the pool
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 15/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- sqlite
- Domain
- database
Research direction
The payload names no source files, so start by finding how Sqlite.Db pooled connections and Sqlite.Transaction are handled in the platform code. Decide whether to add a Sqlite.in_transaction! query or an InTransaction variant on Sqlite.QueryError, which is a design choice the thread has not settled. Done means a pooled statement run inside an open transaction on the same request gets a clear error or returns true, with tests covering both cases.
Written by the indexing model from the issue text.
Description
Summary
Please give a way to tell that the current request already holds a transaction on the Sqlite.Db pool. Two possible forms:
# a query
Sqlite.in_transaction! : Sqlite.Db => Bool # true while this request has an open Sqlite.Transaction on this pool
# or an opt-in refusal: a pooled statement, run while the same request holds an open transaction, fails
Sqlite.QueryError : [.., InTransaction, ..]
Why it is needed
A database library on top of Sqlite gives the application a transaction like this:
conn.transaction!(|tx|
tx.run!(debit)? # correct: goes through Sqlite.Transaction
conn.run!(credit)? # mistake: uses the pool, which the closure captured
Ok({})
)
The second call is a programming error. The library should refuse it at run time with a clear error, for example Busy(InTransaction).
The library cannot detect it alone:
connis an immutable value, created before the transaction started. Starting a transaction cannot mark it as busy.- Roc has no mutable state that a closure can share, so the library cannot keep its own "transaction open" flag.
- Only the platform knows which pooled connections are leased to the current request.
Current behaviour without it
On basic-webserver the wrong call runs outside the transaction, on another pooled connection:
| Wrong call | Result |
|---|---|
| A read | It sees only committed data, not the transaction's own writes |
| A write | It waits for the lock that the request's own transaction holds. It fails with SQLITE_BUSY after the busy timeout. A library that retries the transaction on busy then repeats the cycle |
Nothing is corrupted, but the request is slow and the error is confusing.
Priority
Not a blocker. Libraries can document "inside a transaction body, use the transaction handle". This is a wanted feature: it turns a slow, confusing failure into an immediate, clear run-time error.
- Dominant language
- HTML
- Stars
- 110
- Forks
- 25
- Avg merge
- 18h 28m
- Merged PRs (30d)
- 16
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from roc-lang/basic-webserver
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
roc-lang/basic-webserver#277 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
roc-lang/basic-webserver#274 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
roc-lang/basic-webserver#273 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
roc-lang/basic-webserver#265 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 28/100
roc-lang/basic-webserver#231 ·
Maintainers usually reply within 1 day
All issues in roc-lang/basic-webserver
Similar issues
-
Fail backup preflight when database index check detects corruptionPossibly taken @prashantw12 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
theforeman/foremanctl#1012 ·
Maintainers usually reply within 3 days
-
automated avec-intentions-de-vote new-poll
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
MieuxVoter/presidentielle2027#376 · 1 comment ·
Maintainers usually reply within 1 day
-
list_tables: a column with several CHECK constraints shows only the first oneMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
supabase/mcp#668 · 1 comment ·
Maintainers usually reply within 1 day
-
[BUG] School of the Month: a ranking-1 school that the mentor didn't pick is excluded as a recent winner for a yearPossibly taken @arshil42 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
omegaup/omegaup#10617 · 1 comment ·
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day