Skip to content

test(rpc): make the connection-cap test wait until the hog holds the slot - #77

Merged
CryptoJones merged 1 commit into
mainfrom
fix/rpc-cap-test-hog-race
Oct 24, 2026
Merged

CryptoJones merged 1 commit into
mainfrom
fix/rpc-cap-test-hog-race

Conversation

@CryptoJones

Copy link
Copy Markdown
Owner

Cause

connection_cap_refuses_the_surplus_connection failed again on main after #76 merged (run 40124250632, on 955ec61). #76 removed the port race, so this failure came from a second race inside the test.

The test runs the server with SCYLLA_RPC_MAX_CONN=1. First, a readiness client runs info and exits. Then the test opens a raw, silent "hog" connection to fill the one slot, sleeps 500 ms, and expects the next client to be refused. The problem is that the server frees the readiness client's slot asynchronously, when its connection task ends. If the hog arrives before that, the server sees the slot still taken and drops the hog itself. The slot then frees, and the "surplus" client gets it and succeeds (exit 0).

Fix

The test now checks that the hog really holds the slot before it tries the surplus client. A refused hog reads EOF right away. A hog that holds the slot reads nothing, because the server is waiting for its handshake (10 s by default), so the read times out. The test reconnects the hog until the read times out, with a 10 s deadline. This replaces the fixed 500 ms sleep. The assertion itself is unchanged.

Only crates/scylla-rpc/tests/remote.rs changes.

Ran

  • cargo fmt --all
  • cargo clippy --workspace --all-targets -- -D warnings: clean
  • cargo test --workspace --locked: all pass
  • cargo test -p scylla-rpc --test remote --locked, 20 runs: 0 failures
  • cargo test -p scylla-rpc -p scylla-graphql -p scylla-serve --locked, 3 runs: all pass

Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/

🤖 Generated with Claude Code

https://claude.ai/code/session_01JMTyE9inRv7Knv6jkmgDZs

…slot

connection_cap_refuses_the_surplus_connection still failed on main after #76.
The port race was gone; this failure was a second race inside the test. The
readiness client's slot is freed asynchronously on the server, so the raw "hog"
connection could arrive while that slot was still counted. The server then
refused the hog itself, and the "surplus" client got the free slot and
succeeded.

The test now checks that the hog really holds the slot before it tries the
surplus client. A refused hog reads EOF; a hog holding the slot reads nothing,
because the server is waiting for its handshake. The test reconnects until the
hog holds the slot. This replaces the fixed 500 ms sleep.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JMTyE9inRv7Knv6jkmgDZs
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 5410e37c-ba28-485e-9648-060c34869862
Commits

Reviewing files that changed from the base of the PR and between 955ec61 and 24ae097.

Files selected for processing: 1
  • crates/scylla-rpc/tests/remote.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Recent review details
Context from checks skipped due to timeout: 2
  • GitHub Check: test
  • GitHub Check: engine-service
Additional context used
Code guidelines: 1
ARCHITECTURE_REVIEW.md — auto-discovered
Path-based instructions: 1
Applicability reference: AGENTS.md: # Agent Guidelines & Release Procedure If cutting a release: If addressing items from `BACKLOG.md` or `ARCHITECTURE_REVIEW.md`, update their statuses and tracking notes.

CodeRabbit inference engine (ARCHITECTURE_REVIEW.md)

Files:

  • crates/scylla-rpc/tests/remote.rs
Additional comments: 1
crates/scylla-rpc/tests/remote.rs: 1

136-136: LGTM!

Also applies to: 152-167

📝 Summary

Summary by CodeRabbit

  • Tests
    • Updated connection-cap coverage to retry TCP connections until the server’s single connection slot is occupied.
    • The test now detects refused connections through EOF and recognizes an occupied slot through a read timeout, rather than relying on a fixed delay. This makes the connection-cap test’s checks reflect observed connection behavior.

The connection-cap test replaces a fixed delay with retries. It checks raw TCP connections until a read timeout indicates that the server holds its single connection slot, or the 10-second limit expires.

Changes: Connection-cap test

Layer / File(s) Summary
Retry raw connections until the slot is held
crates/scylla-rpc/tests/remote.rs
The test imports ErrorKind and Read. It retries raw TCP connections after EOF or another read result, and detects a held connection slot with a read timeout. The test fails if no attempt holds the slot within 10 seconds.

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Low · up to 24ae0

The test can remain flaky or validate surplus-connection behavior before the hog actually occupies the slot.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: making the RPC connection-cap test wait until the hog connection holds the server slot.
Description check Passed The description directly explains the race condition, the retry-based fix, the test behavior, and the validation results.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@CryptoJones
CryptoJones merged commit 3774e60 into main Oct 24, 2026
3 checks passed
@CryptoJones
CryptoJones deleted the fix/rpc-cap-test-hog-race branch October 24, 2026 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant