Skip to content

libsql-server: keepalive on the replica's gRPC channel to the primary - #2343

Open
jrparks wants to merge 4 commits into
tursodatabase:mainfrom
jrparks:up/replica-keepalive
Open

jrparks wants to merge 4 commits into
tursodatabase:mainfrom
jrparks:up/replica-keepalive

Conversation

@jrparks

@jrparks jrparks commented Dec 1, 2026

Copy link
Copy Markdown

A replica whose replication stream loses its peer without a FIN or RST keeps the TCP connection "established" and waits on the stream forever. The replicator never sees an error, so it never reconnects, and the replica silently serves stale reads.

Observed in practice: the primary was restarted behind a load-balanced virtual IP. The replica logged one transport error, then stopped replicating without any further log line for about 12 hours (the connection was established on the replica and gone on the primary). A network partition has the same effect.

This sends HTTP/2 pings every 10s (20s timeout, also while idle) on the replica's gRPC channel and enables TCP keepalive (30s) on its connector. A dead stream now fails within about 30s and the existing retry loop handshakes with the primary again. No behaviour change on a healthy connection. Two small hunks: config.rs (channel builder) and main.rs (connector).

The branch sits on top of the two CI commits from #2317 so the Extensions and Go checks can run; they drop out once #2317 merges. cargo check -p libsql-server passes.

ubuntu-latest moved to Ubuntu 26.04 between 2026-11-08 and 2026-11-11.
On 26.04 these jobs fail before reaching any test: CMake 4 rejects
wabt-sys 0.6.1 (cmake_minimum_required < 3.5) and the sqlite3_capi
bindings come out empty. The same jobs pass on 24.04, which every
green run so far used. Pinning restores CI for open PRs until the
toolchain issues are fixed properly.

Refs tursodatabase#2315
Go 1.27.4 refuses to link libsql_experimental.a: "disallowed LTO section
".llvmbc" in #cgo LDFLAGS". setup-go '>=1.21' picked 1.27.4 on the
first run of this PR; the last green run used 1.27.3. Pin until the
static library is built without embedded bitcode.

Refs tursodatabase#2315
A replica whose replication stream loses its peer without a FIN or RST
(the primary restarted behind a load-balanced virtual IP, a network
partition) keeps the TCP connection "established" and waits on the
stream forever. The replicator never sees an error, so it never
reconnects, and the replica silently serves stale reads.

Send HTTP/2 pings every 10s (20s timeout, also while idle) on the
gRPC channel and enable TCP keepalive (30s) on its connector. A dead
stream now fails within ~30s and the existing retry loop handshakes
with the primary again.

This branch has not been deployed

No deployments
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