Skip to content

Commit 70c5340

Browse files
committed
gw: prewarm port_attrs cache at registration time
When a CVM registers without port_attrs (legacy CVM, or compose_hash mismatch invalidated the cache), enqueue a background fetch right away instead of waiting for the first proxied connection to discover the miss. Reduces the window during which the fast path returns a wrong `pp = false` because the cache hasn't been populated yet. The fetcher dedupes in-flight ids, so this is safe to enqueue on every registration that ends up without cached attrs.
1 parent 3504c8a commit 70c5340

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

gateway/src/main_service.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,12 @@ impl Proxy {
434434
if let Err(err) = state.reconfigure() {
435435
error!("failed to reconfigure: {err:?}");
436436
}
437+
// Capture the prewarm decision before continuing under the lock.
438+
// If the instance arrived without port_attrs (legacy CVM, or
439+
// compose_hash mismatch invalidated the cache), enqueue a
440+
// background fetch so the first proxied connection isn't the one
441+
// that triggers it. The fetcher dedupes, so this is safe.
442+
let needs_prewarm = client_info.port_attrs.is_none();
437443
let gateways = state.get_active_nodes();
438444
let servers = gateways
439445
.iter()
@@ -457,6 +463,10 @@ impl Proxy {
457463
}),
458464
gateways,
459465
};
466+
drop(state);
467+
if needs_prewarm {
468+
let _ = self.port_attrs_tx.send(instance_id.to_string());
469+
}
460470
self.notify_state_updated.notify_one();
461471
Ok(response)
462472
}

0 commit comments

Comments
 (0)