Skip to content

LibsqlConnection state is not synchronized #105

Closed

Description

@magnusp

#89 serializes statement close and execute with a statement lock. The connection fields baton, baseUrl, autoCommit, closed, and the cached metadata are plain fields with no synchronization. sqlite-jdbc serializes every call on its DB object.

Failing interleavings:

  • Two statements on one non-auto-commit connection read the same baton. One request fails as a reused baton, and the last response overwrites the stream state.
  • commit() runs between another thread's ensureTransactionStarted and its send.
  • close() races executeStatement, so a stream can stay open.

The statement lock does not order calls into the connection. The statement never calls the connection while it holds its lock, except through checkClosed, which takes no lock. A connection-level lock therefore adds no lock-ordering risk.

Expected:

  • Hold one connection-level lock around each pipeline round trip and around setAutoCommit, commit, rollback, and close.
  • Add a concurrency test with two threads on one non-auto-commit connection.

Activity

  1. added
    bugSomething isn't working
    P2Normal priority: edge case, feature gap, or test/process improvement
    on Oct 22, 2026
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

    P2Normal priority: edge case, feature gap, or test/process improvementbugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions