Skip to content

Commit 2085d5b

Browse files
TheSentinel454Elrondclaude
committed
db: tighten read-pool warm docs, log field, and test per review
- Reader sizing advice: size for the ceiling times relay processes, counting rolling-deploy overlap, since every boot now warms to the ceiling. - Rename the warm log field `opened` to `held`: it includes reused floor connections, not only dials. - Note that boot can have the floor plus READER_WARM_CONCURRENCY dials in flight. - Drop an assertion that could not fail on the current-thread test runtime. Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz> Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Luke Tornquist <[email protected]>
1 parent e33c7da commit 2085d5b

2 files changed

Lines changed: 16 additions & 17 deletions

File tree

‎crates/buzz-db/src/runtime/mod.rs‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,8 @@ fn read_budget_from_ms(ms: u64) -> Option<Duration> {
574574
struct ReaderWarmReport {
575575
/// Connections the pass aimed to hold: the pool's ceiling.
576576
target: u32,
577-
/// Connections opened (or reused idle) and then released back to idle.
577+
/// Connections held at the end of the pass, then released back to idle:
578+
/// the ones it dialed plus any idle floor connections it reused.
578579
held: u32,
579580
/// Acquires that errored or timed out.
580581
failed: u32,
@@ -997,8 +998,11 @@ impl Db {
997998
/// (the reader logs `could not accept SSL connection: EOF detected`), the
998999
/// read falls back to the writer, and the next read dials again. Under a
9991000
/// fleet-wide burst that loop turns brief reader slowness into writer pool
1000-
/// exhaustion. The floor is per relay process: size the reader's
1001-
/// `max_connections` for the floor times the number of relay processes.
1001+
/// exhaustion. The floor is per relay process, but every boot also
1002+
/// warms the pool to its ceiling ([`Db::warm_read_pool`]) and keeps the
1003+
/// surplus until `idle_timeout` reaps it: size the reader's
1004+
/// `max_connections` for the ceiling times the number of relay
1005+
/// processes, counting old and new pods that overlap in a rolling deploy.
10021006
fn reader_min_connections(max_connections: u32) -> u32 {
10031007
(max_connections / 5).max(1).min(max_connections)
10041008
}
@@ -1174,7 +1178,9 @@ impl Db {
11741178
/// starting alongside its peers does not stampede the reader with
11751179
/// simultaneous TCP+TLS+SCRAM handshakes (a stampede is what pushes a
11761180
/// dial past [`Db::READER_ACQUIRE_TIMEOUT`]), large enough that a full
1177-
/// pool is warm within a handful of dial times.
1181+
/// pool is warm within a handful of dial times. sqlx's floor maintenance,
1182+
/// triggered by the boot ping, dials alongside the first wave, so a
1183+
/// booting pod can have up to the floor plus this many dials in flight.
11781184
const READER_WARM_CONCURRENCY: u32 = 5;
11791185

11801186
/// Connections the next warm wave should open: the remaining shortfall,
@@ -1202,16 +1208,16 @@ impl Db {
12021208
if report.held < report.target {
12031209
tracing::warn!(
12041210
target = report.target,
1205-
opened = report.held,
1211+
held = report.held,
12061212
failed = report.failed,
12071213
elapsed_ms,
1208-
"read pool warm-up opened fewer connections than its ceiling; \
1214+
"read pool warm-up holds fewer connections than its ceiling; \
12091215
the rest dial on demand (warm-up is best effort)"
12101216
);
12111217
} else {
12121218
tracing::info!(
12131219
target = report.target,
1214-
opened = report.held,
1220+
held = report.held,
12151221
failed = report.failed,
12161222
elapsed_ms,
12171223
"read pool warmed to its ceiling"

‎crates/buzz-db/src/runtime/tests/reader_pool_postgres_tests.rs‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,9 @@ async fn reader_boot_ping_warms_pool_to_min_connections() {
127127
}
128128

129129
/// After the boot ping the background warm pass opens the reader pool to its
130-
/// ceiling and releases every connection idle. The caller must not wait for
131-
/// it: `spawn_read_pool_boot_ping` returns with the pool still empty. Without
132-
/// the warm pass the pool stops at the floor; if the pass closed its
133-
/// connections instead of releasing them, `size` and `idle` never reach the
134-
/// ceiling together.
130+
/// ceiling and releases every connection idle. Without the warm pass the pool
131+
/// stops at the floor; if the pass closed its connections instead of
132+
/// releasing them, `size` and `idle` never reach the ceiling together.
135133
#[tokio::test]
136134
#[ignore = "requires Postgres"]
137135
async fn reader_boot_ping_warms_pool_to_max_in_background() {
@@ -154,11 +152,6 @@ async fn reader_boot_ping_warms_pool_to_max_in_background() {
154152
);
155153

156154
db.spawn_read_pool_boot_ping();
157-
assert_eq!(
158-
read_pool.size(),
159-
0,
160-
"spawning the ping and warm pass must not wait on them"
161-
);
162155

163156
await_idle_floor(&read_pool, max).await;
164157
// Settled at the ceiling and no further.

0 commit comments

Comments
 (0)