Skip to content

Fix socket listener connection error callback_idx assertion failure - #6527

Draft
xShinnRyuu wants to merge 1 commit into
valkey-io:mainfrom
xShinnRyuu:fix/socket-listener-callback-idx
Draft

Fix socket listener connection error callback_idx assertion failure#6527
xShinnRyuu wants to merge 1 commit into
valkey-io:mainfrom
xShinnRyuu:fix/socket-listener-callback-idx

Conversation

@xShinnRyuu

Copy link
Copy Markdown
Collaborator

Summary

Fixes #6434

When client creation fails in listen_on_client_stream, the error response was sent with callback_idx = u32::MAX (4294967295) instead of the expected callback_idx = 0. This caused an assertion failure in 14 socket_listener standalone cluster tests when the connection to the standalone server failed transiently in CI:

assertion `left == right` failed
  left: 4294967295
 right: 0

Root Cause

The connection request proto (ConnectionRequest) does not carry a callback_idx field. The protocol convention is that connection responses always use index 0. The success path in create_client correctly used 0, but the error paths in listen_on_client_stream used u32::MAX.

Changes

  1. Introduces CONNECTION_RESPONSE_CALLBACK_IDX constant (= 0) in socket_listener.rs and uses it consistently in both the success and error paths for connection responses.
  2. Adds a connection retry strategy (3 retries with exponential backoff) to the socket listener test connect_to_redis helper, so transient server startup delays in CI do not cause immediate connection failures.

Testing

  • cargo check --features socket-layer passes (library and tests compile)
  • The fix ensures that even when a connection attempt fails, the error response carries the correct callback index (0), so the test assertion failure 4294967295 != 0 cannot recur.
  • The retry strategy provides resilience against transient server startup delays.

When client creation fails in listen_on_client_stream, the error response
was sent with callback_idx = u32::MAX (4294967295) instead of the expected
callback_idx = 0. This causes an assertion failure in tests when the
connection to the standalone server fails transiently:

  assertion `left == right` failed
    left: 4294967295
   right: 0

The connection request does not carry a callback_idx field; the protocol
convention is that the response always uses index 0. The success path in
create_client correctly used 0, but the error paths in
listen_on_client_stream used u32::MAX.

This commit:
1. Introduces CONNECTION_RESPONSE_CALLBACK_IDX constant (= 0) and uses it
   consistently in both the success and error paths for connection responses.
2. Adds a connection retry strategy (3 retries with exponential backoff) to
   the socket listener test connect_to_redis helper, so transient server
   startup delays in CI do not cause immediate connection failures.

Fixes valkey-io#6434
@xShinnRyuu
xShinnRyuu requested a review from a team as a code owner July 14, 2026 17:13
@valkey-review-bot

Copy link
Copy Markdown
Contributor

The single commit in this PR is missing the required Signed-off-by: trailer and its subject does not follow the repository's Conventional Commit format. CONTRIBUTING.md and SUBMITTING_PRS.md require every commit to include both a DCO signoff and a <type>(<scope>): <description> subject, so please amend the commit message before merge.

@valkey-review-bot valkey-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found one remaining test-side issue in the socket-listener fix: the new retry budget is still much smaller than the server-startup race this helper is trying to absorb, so the flake can still reappear on slower CI. I also left a separate issue comment for the missing DCO/conventional-commit commit message requirements.

use_tls: use_tls.to_bool(),
cluster_mode,
request_timeout: Some(REQUEST_TIMEOUT_MS),
connection_retry_strategy: Some(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These three retries only shrink the startup race instead of making the fixture deterministic. In the failure mode from #6434, the client creation path feeds this config straight into RetryStrategy::new() (glide-core/src/client/standalone_client.rs:162-168), and with { exponent_base: 2, factor: 2, number_of_retries: 3 } that bounded iterator is only 4/8/16ms (glide-core/redis-rs/redis/src/retry_strategies.rs:57-68,124-136). The rest of the test suite already treats RedisServer::new_*() as asynchronous startup and waits for readiness (glide-core/tests/test_client.rs:84-97, glide-core/tests/utilities/mod.rs:535-568), so if CI takes longer than ~28ms to accept connections this helper still fails before the server is ready. Using the existing readiness helper here would remove the flake without changing the client configuration under test.

@xShinnRyuu
xShinnRyuu marked this pull request as draft July 17, 2026 20:24
@xShinnRyuu xShinnRyuu self-assigned this Jul 17, 2026
@xShinnRyuu xShinnRyuu added Flaky-tests 🐦 Flaky-tests AI Generated For any AI generated content from our own workflows/maintainers. Rust ⚙️ Pull requests that update rust code labels Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated For any AI generated content from our own workflows/maintainers. Flaky-tests 🐦 Flaky-tests Rust ⚙️ Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Rust][Flaky Test] test_socket_listener standalone cluster tests - assertion failed (4294967295 != 0)

2 participants