Add v5 primitive-life session wire protocol
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m56s
Foundation / checks (client) (push) Successful in 12m41s
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 2m43s
Foundation / checks (network) (push) Canceled after 13m22s
Foundation / checks (checks) (push) Canceled after 15m28s

This commit is contained in:
dingo
2026-10-10 13:15:20 -04:00
parent 066b85333b
commit 8c6e244dad
8 changed files with 248 additions and 32 deletions
+10 -3
View File
@@ -386,8 +386,10 @@ struct RegionSessions::Impl {
void datagram(Connection& c, std::span<const std::uint8_t> bytes, Clock::time_point now) {
if (c.state == State::closing)
return;
const auto decoded = network::decode_session(bytes);
if (c.state != State::established || !decoded)
std::uint16_t wire_version{};
const auto decoded = network::decode_session(bytes, &wire_version);
if (c.state != State::established || !decoded ||
wire_version != network::session_protocol_version)
return close(c, SessionCloseReason::protocol, now);
if (const auto* ack = std::get_if<network::SnapshotAck>(&*decoded))
return replication.acknowledge(c.session, *ack);
@@ -527,13 +529,18 @@ struct RegionSessions::Impl {
return;
if (c.state == State::pending) // Nothing is expected before Welcome.
return close(c, SessionCloseReason::protocol, now);
const auto decoded = network::decode_session(bytes);
std::uint16_t wire_version{};
const auto decoded = network::decode_session(bytes, &wire_version);
if (!decoded)
return close(c,
decoded.error() == network::SessionCodecError::unsupported_version
? SessionCloseReason::unsupported_version
: SessionCloseReason::protocol,
now);
// v5 has a codec and schema, but per-connection negotiation and life handling
// land in the following server gate. Do not silently accept v5 and answer v4.
if (wire_version != network::session_protocol_version)
return close(c, SessionCloseReason::unsupported_version, now);
if (c.state == State::hello) {
if (const auto* m = std::get_if<network::SessionHello>(&*decoded))
return hello(c, *m, now_seconds, now);