Intermittent SQLite transaction error on read operations (cannot start a transaction within a transaction)

Aperta
#845 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
cpp, sqlite
Ambito
backend, databases

Direzione di ricerca

Start with the inTransaction() check in src/lib/object_store/DB.cpp and transaction start logic in src/lib/object_store/DBObject.cpp, both linked in the issue. Trace how concurrent reads share the SQLite connection and inspect the related transaction tests. Done means simultaneous read operations no longer fail with “cannot start a transaction within a transaction” and existing transaction behavior remains correct.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

When performing multiple simultaneous read operations (e.g., from different threads) using the SQLite backend, the following error occurs:

SQLITE3: cannot start a transaction within a transaction (1)
Steps to Reproduce
  1. Open multiple threads or sessions that execute read operations (e.g., enumerate objects, get token info) concurrently against the same token/slot.
  2. Observe backend logs or error output when these operations overlap in time.
Expected Behavior

Concurrent read operations (which start read-only SQLite transactions) should be able to called from concurrent threads without errors when using a shared database connection in SQLITE_OPEN_FULLMUTEX mode.

Actual Behavior

The backend emits the error:

SQLITE3: cannot start a transaction within a transaction (1)

and one or more read operations fails. Specifically, this happens when reading multiple objects from the same slot/token simultaneously from multiple backend application threads.

Details

Each read operation attempts to start a new read-only transaction (BEGIN) on the same underlying sqlite3* connection. But the two concurrent reads can race: both can pass the DBObject inTransaction() check, then both attempt to start a transaction (Time of Check/Time of Use), but SQLite only allows a single active transaction per connection, causing the second BEGIN to fail.

Lingua principale
C++
Stelle
1.1k
Fork
434
Merge medio
12g 14h
PR unite (30g)
2

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di softhsm/SoftHSMv2

Tutte le issue di softhsm/SoftHSMv2

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.