Repository navigation
fix(kawa-h1): clear the sticky-session answer when reusing a keep-alive slot - #1833
Merged
Merged
Conversation
…ve slot HttpContext::reset kept sticky_session across the requests of one HTTP/1 keep-alive connection. backend_from_request writes it only when the request's frontend sticks, and on_response_headers answers any value left there with a Set-Cookie, so a request to a frontend that does not stick, sent after one to a sticky frontend on the same connection, reached its own backend but was answered with the previous request's SOZUBALANCEID cookie. reset now clears it. HTTP/2 is not affected: Context::create_stream builds a fresh HttpContext for every stream, recycled slots included. The assertion of test_reset_preserves_connection_state that reset keeps sticky_session encoded the defect and is removed; the new unit test and e2e test_keep_alive_does_not_carry_a_sticky_cookie_over pin the fix. Fixes #1822 Signed-off-by: Florentin Dubois <[email protected]>
…a pin The cookie is answered on a frontend that does not stick, whose router ignores it, so it names a backend of another cluster without pinning the client to it. Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1822
Problem
On one HTTP/1 keep-alive connection, a request to a sticky frontend followed by a request to a frontend that does not stick: the second request reaches its own backend, but its response carries the first request's
Set-Cookie: SOZUBALANCEID=….CAUSE:
lib/src/protocol/kawa_h1/editor.rsHttpContext::resetleavessticky_sessionin place ->lib/src/protocol/mux/router.rsbackend_from_requestwritessticky_sessiononly when the frontend sticks, so the non-sticky request inherits the stale value -> SYMPTOM:editor.rson_response_headersemitsSet-Cookiefor any retainedsticky_sessionthat differs fromsticky_session_found(Noneon the second request).Fix
HttpContext::resetclearssticky_session, and its postconditiondebug_assert!now checks it. Other fields that survivereset(cluster_id,backend_id, ...) are left alone: as the issue says, each needs its own path-specific oracle before being claimed as a defect.HTTP/2 is not affected:
Context::create_stream(lib/src/protocol/mux/mod.rs) builds a freshHttpContext::new(...)for every stream and assigns it tostream.contexton the recycled-slot path too; the onlyHttpContext::resetcaller is the H1 keep-alive branch inlib/src/protocol/mux/h1.rs.Tests
reset_clears_the_sticky_session_answer_of_the_previous_request(editor.rs): a response edited with a sticky answer carries the cookie (premise), and afterresetthe next response carries none.test_keep_alive_does_not_carry_a_sticky_cookie_over(e2e/src/tests/tests.rs): stickycluster_0onlocalhost, non-stickycluster_1onplain.localhost, one keep-alive client connection.test_reset_preserves_connection_stateasserted thatresetkeepssticky_session; that assertion encoded the defect reported here, so its setup line and assertion are removed (the rest of the test is unchanged).RED on
bd19a78e(before the fix):Validation (local)
cargo +nightly fmt --check-> exit 0cargo +1.93.1 clippy --all-features --all-targets --locked -- -D warnings-> exit 0RUSTDOCFLAGS="-D warnings" cargo +1.93.1 doc --no-deps --locked -p sozu-lib-> exit 0cargo +1.93.1 test -p sozu-lib --lib --all-features --locked->1593 passed; 0 failedcargo +1.93.1 test -p sozu-e2e --features opentelemetry,splice,simd -- test_keep_alive_does_not_carry_a_sticky_cookie_over test_stick test_keep_alive_rotates_request_id->3 passed;-- sticky affinity->11 passed(full e2e suite left to CI)python3 .github/scripts/check_doc_citations.py --root . --base origin/main-> all OKDocs:
lib/src/protocol/kawa_h1/LIFECYCLE.mdinvariant 4,doc/lifetime_of_a_session.md§6.6, CHANGELOG (Unreleased / Fixed).