Skip to content

fix: release pre-acquired stream IDs#964

Closed
arnabnandy7 wants to merge 1 commit into
scylladb:scylla-4.xfrom
arnabnandy7:fix/pre-acquired-stream-id-leak
Closed

fix: release pre-acquired stream IDs#964
arnabnandy7 wants to merge 1 commit into
scylladb:scylla-4.xfrom
arnabnandy7:fix/pre-acquired-stream-id-leak

Conversation

@arnabnandy7

Copy link
Copy Markdown

Description

What changed

  • Release pre-acquired stream IDs when DriverChannel.write() rejects a request before submitting it to the Netty pipeline.
  • Release reservations when synchronous request construction fails before write() is called.
  • Apply the same handling to:
    • CQL requests
    • prepare requests and secondary prepares
    • graph requests
    • continuous paging requests
  • Release the reservation when a continuous paging callback completes after channel acquisition but before submission.
  • Add regression coverage and update the changelog.

Root cause

Channel selection calls preAcquireId() before returning a channel. Request handlers then perform additional work before the resulting RequestMessage reaches InFlightHandler.

If that work throws, or DriverChannel.write() rejects the request before pipeline submission, InFlightHandler never sees the request and therefore cannot release the reservation. Repeated failures can cause available stream-ID accounting to drift and eventually make healthy channels appear saturated.

Impact

Every successful stream-ID pre-acquisition now ends in one of two outcomes:

  • the request is submitted to InFlightHandler; or
  • the reservation is explicitly released.

Fixes #947.

Validation

mvn -pl core -Dtest=DriverChannelTest,CqlRequestHandlerTest,CqlPrepareHandlerTest test
  • 18 tests passed
  • Formatter and Error Prone checks passed under JDK 17
  • git diff --check passed

Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>
@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@arnabnandy7, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 47 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cd67cdf2-932d-40fe-be27-c20c265e9794

📥 Commits

Reviewing files that changed from the base of the PR and between 3cafb2a and 5900e56.

📒 Files selected for processing (8)
  • changelog/README.md
  • core/src/main/java/com/datastax/dse/driver/internal/core/cql/continuous/ContinuousRequestHandlerBase.java
  • core/src/main/java/com/datastax/dse/driver/internal/core/graph/GraphRequestHandler.java
  • core/src/main/java/com/datastax/oss/driver/internal/core/channel/DriverChannel.java
  • core/src/main/java/com/datastax/oss/driver/internal/core/channel/InFlightHandler.java
  • core/src/main/java/com/datastax/oss/driver/internal/core/cql/CqlPrepareHandler.java
  • core/src/main/java/com/datastax/oss/driver/internal/core/cql/CqlRequestHandler.java
  • core/src/test/java/com/datastax/oss/driver/internal/core/channel/DriverChannelTest.java

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.

@arnabnandy7

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

CodeRabbit chat interactions are restricted to organization members for this repository. Ask an organization member to interact with CodeRabbit, or set chat.allow_non_org_members: true in your configuration.

@dkropachev

Copy link
Copy Markdown

Closing in favor of #965. It covers the same #947 stream-id leak on scylla-4.x, includes the additional pre-acquired-id cleanup paths, and has focused test coverage plus the current CI compatibility fixes.

@dkropachev dkropachev closed this Jul 20, 2026
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.

4.x: Pre-acquired stream id can leak when request fails before InFlightHandler write

2 participants