Skip to content

Gateway can crash on startup because libsql closes connections twice #2070

Closed

Description

libsql 0.9.30 closes a local connection's SQLite handle twice when its last handle is dropped (tursodatabase/libsql#2251, fix waiting in tursodatabase/libsql#2261).
Most of the time nothing happens, sometimes it's an access violation.

#2039 makes this reachable on startup: the 2026.3 import and the probe connection in GatewayDb::open drop connections.
The job queue, the traffic audit and the 2026.3 agent tunnel keep theirs for the whole process, so they never hit it in production.

What I saw on a lab Windows Gateway running the #2039 build (934b26d):

  • 2 of 2 first starts right after an MSI upgrade from 2026.3.0 crashed with 0xc0000005
  • 4 of 50 starts that ran the import crashed, 0 of 40 plain restarts did
  • every dump stops in drop_in_place<libsql::local::connection::Connection> → sqlite3_close_v2

After a crash, service recovery restarts the Gateway 15 minutes later and that start finishes the import, nothing lost.

The same bug is already there in the traffic audit schema reset, and it's probably behind the STATUS_ACCESS_VIOLATION flakes in the Windows tests.

Options:

Note

LLM-assisted content (no human feedback).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions