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

Đang mở
#845 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
cpp, sqlite
Lĩnh vực
backend, databases

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
C++
Star
1.1k
Fork
434
Merge trung bình
12 ngày 14 giờ
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của softhsm/SoftHSMv2

Tất cả issue của softhsm/SoftHSMv2

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.