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

オープン
#845 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
cpp, sqlite
領域
backend, databases

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
C++
スター
1.1k
フォーク
434
平均マージ
12日 14時間
マージ済み PR(30日)
2

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

softhsm/SoftHSMv2 のほかの issue

softhsm/SoftHSMv2 の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。