Skip to content

bug(hive): SQLiteHiveStore connection is shared across threads without a lock #927

Closed

Description

@AmitoVrito

Found while reviewing #924.

SQLiteHiveStore (src/synapsekit/hive/aggregator.py) opens its connection with sqlite3.connect(..., check_same_thread=False) but guards it with no mutex. Every store operation (put/list/revoke) is dispatched from a different worker thread via asyncio.to_thread (the in-process transport). For a pooled/shared memory feature, concurrent submit + suggestions on one connection can raise sqlite3.ProgrammingError/OperationalError or corrupt cursor state.

The comparable marketplace/registry.py guards its connection with a threading.RLock(); this store does not.

Fix: wrap all execute/executescript/commit calls in a threading.Lock/RLock (or open a connection per call). Add a concurrency regression test that fires N to_thread submits at once.

Activity

  1. added
    bug
    on Aug 12, 2026
  2. added 2 commits that reference this issue on Aug 12, 2026
    af7311b
    7576299
  3. AmitoVrito commented on Aug 12, 2026

    @AmitoVrito
    CollaboratorAuthor

    Fixed in #924 (commit 7576299) — all SQLiteHiveStore access is now serialized through a threading.RLock, with a concurrent-to_thread regression test. CI green. Lands on main when #924 merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions