Skip to content

fix: release pre-acquired stream ids#965

Open
dkropachev wants to merge 1 commit into
scylladb:scylla-4.xfrom
dkropachev:dk/947-release-preacquired-stream-id
Open

fix: release pre-acquired stream ids#965
dkropachev wants to merge 1 commit into
scylladb:scylla-4.xfrom
dkropachev:dk/947-release-preacquired-stream-id

Conversation

@dkropachev

@dkropachev dkropachev commented Jul 20, 2026

Copy link
Copy Markdown

Summary

  • release pre-acquired stream-id reservations when request setup fails before the write is submitted to InFlightHandler
  • cover CQL, prepare, graph, continuous, admin reprepare, direct channel-handler requests, and closed pooled channels

Fixes #947.
Depends on #966 for latest Scylla IT compatibility.

Tests

  • JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 PATH=/usr/lib/jvm/java-17-openjdk-amd64/bin:$PATH mvn -pl core -Dtest=DriverChannelTest,CqlRequestHandlerTest,DefaultSessionPoolsTest,CqlPrepareHandlerTest,GraphRequestHandlerTest,ContinuousCqlRequestHandlerTest,ReprepareOnUpTest test

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

Next review available in: 42 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: 31c34e56-d324-46a6-a337-d512f3d4093f

📥 Commits

Reviewing files that changed from the base of the PR and between 3c4fed0 and 29080a7.

📒 Files selected for processing (15)
  • 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/adminrequest/AdminRequestHandler.java
  • core/src/main/java/com/datastax/oss/driver/internal/core/adminrequest/ThrottledAdminRequestHandler.java
  • core/src/main/java/com/datastax/oss/driver/internal/core/channel/ChannelHandlerRequest.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/main/java/com/datastax/oss/driver/internal/core/session/DefaultSession.java
  • core/src/test/java/com/datastax/oss/driver/internal/core/channel/DriverChannelTest.java
  • core/src/test/java/com/datastax/oss/driver/internal/core/cql/CqlRequestHandlerTest.java
  • core/src/test/java/com/datastax/oss/driver/internal/core/cql/PoolBehavior.java
  • core/src/test/java/com/datastax/oss/driver/internal/core/session/DefaultSessionPoolsTest.java
  • core/src/test/java/com/datastax/oss/driver/internal/core/session/ReprepareOnUpTest.java
📝 Walkthrough

Walkthrough

The change adds explicit cancellation for pre-acquired stream IDs when request preparation, throttling, channel selection, or write submission fails before InFlightHandler receives the request. DriverChannel and InFlightHandler expose cancellation helpers. Multiple request handlers now guard writes with submission tracking and cleanup. Throttled admin requests cancel externally acquired IDs once. Tests cover rejected writes, decoration failures, closed channels, and throttling failures.

Sequence Diagram(s)

sequenceDiagram
  participant RequestFlow
  participant DriverChannel
  participant InFlightHandler
  RequestFlow->>DriverChannel: pre-acquire stream ID
  RequestFlow->>DriverChannel: submit request
  alt submission fails before in-flight handling
    RequestFlow->>DriverChannel: cancelPreAcquireId()
    DriverChannel->>InFlightHandler: cancel pre-acquired ID
  else submission succeeds
    DriverChannel->>InFlightHandler: write request
  end
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.08% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address #947 by releasing pre-acquired IDs on early failures across the covered handlers and closed-channel cases.
Out of Scope Changes check ✅ Passed The diff stays focused on stream-id cleanup and related tests, with no obvious unrelated changes.
Title check ✅ Passed The title clearly summarizes the main change: releasing pre-acquired stream IDs.
Description check ✅ Passed The description matches the changeset and explains the cleanup paths and test coverage.

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.

@dkropachev
dkropachev force-pushed the dk/947-release-preacquired-stream-id branch from d8e357b to 3c4fed0 Compare July 20, 2026 22:13
Release stream-id reservations when a channel has been pre-acquired but the request fails before it is submitted to InFlightHandler.

Cover CQL, prepare, graph, continuous, admin reprepare, direct channel-handler requests, and closed pooled channels.

Fixes scylladb#947.

Signed-off-by: Dmitry Kropachev <dmitry.kropachev@gmail.com>
@dkropachev
dkropachev force-pushed the dk/947-release-preacquired-stream-id branch from 3c4fed0 to 29080a7 Compare July 20, 2026 23:48
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

1 participant