Skip to content

A gentle deadlock monitor - #2262

Closed
aredridel wants to merge 10 commits into
tursodatabase:mainfrom
spice-labs-inc:as/gentle-deadlock-monitor
Closed

A gentle deadlock monitor#2262
aredridel wants to merge 10 commits into
tursodatabase:mainfrom
spice-labs-inc:as/gentle-deadlock-monitor

Conversation

@aredridel

Copy link
Copy Markdown

No description provided.

aredridel and others added 10 commits May 26, 2026 23:21
- connect_timeout: max time to establish S3 connection, configurable
  with LIBSQL_BOTTOMLESS_S3_CONNECT_TIMEOUT_SECS (default 5s)
- read_timeout: max time to wait for first byte of response,
  configurable with LIBSQL_BOTTOMLESS_S3_READ_TIMEOUT_SECS (default 5s)
- No operation timeout, allowing retries to continue indefinitely
- Unit test: verifies connect_timeout and read_timeout are applied to
  AWS SDK config

Integration tests:
  - verify that the read_timeout fires when the server hangs
  - verify the S3 connect timeout using a blackhole IP
  - verify behavior when there is a timeout during initial replication
…etes

Moves default namespace creation (which triggers bottomless restore on
primary and initial replication handshake on replica) to before any
HTTP/Hrana/gRPC acceptors start serving. This ensures the database is
fully initialized before clients can connect.

The admin API begins accepting connections right away, allowing
operators to inspect state during initialization and to allow the admin
port to act as a startup liveness check, and letting the main ports act
as a readiness check.

Also fixes test flakiness by running the mock S3 server on a dedicated
OS thread so it survives past individual test runtimes, and replacing
all env-var-based Options configuration with explicit structs to
eliminate cross-test env var races.
Tests panic with connection refused because they open a database
connection before it is fully started. We add an HTTP-poll loop
(matching the pattern used in replication.rs and other cluster tests) to
wait for the replica's user API endpoint to become responsive before
proceeding.
Add timeouts & defer listening until ready.
…eadlock

The deadlock monitor panicked via sender.try_send(...).unwrap() on the
second iteration after a single missed pong: the mpsc channel has
capacity 1, so when the main runtime stalled (e.g. a slow S3 checkpoint
upload) the previous Ping stayed queued and try_send returned Full,
panicking instead of reporting the deadlock. The intended
std::process::exit(1) was commented out, leaving the unwrap as the
sole failure path.

A single missed pong is a stall, not proof of deadlock — it can be a
slow checkpoint, blocking I/O, or overload. Count consecutive misses
and exit the process only after sustained unresponsiveness (3 misses),
so a healthy-but-busy server survives a transient slow operation while
a real deadlock still brings the process down for a supervisor restart.
@aredridel

Copy link
Copy Markdown
Author

Whoops. Wrong repo.

@aredridel aredridel closed this Jul 27, 2026
@aredridel
aredridel deleted the as/gentle-deadlock-monitor branch July 27, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant