Skip to content

fix: shutdown blocks for unary deadline time - #1848

Open
toddbaert wants to merge 1 commit into
mainfrom
fix/clean-up-shutdown
Open

fix: shutdown blocks for unary deadline time#1848
toddbaert wants to merge 1 commit into
mainfrom
fix/clean-up-shutdown

Conversation

@toddbaert

Copy link
Copy Markdown
Member
  • an earlier refactor changed the way the shutdown works, in order to remove a sleep
  • resulted in incorrect order of some method calls in shutdown - we need to await AFTER we kill the channel
  • without this fix, we always awaited for the configured unary RPC deadline before actually closing the channel

* an earlier refactor changed the way the shutdown works, in order to remove a sleep
* resulted in incorrect order of some method calls in shutdown - we need to await AFTER we kill the channel
* without this fix, we always awaited for the configured unary RPC deadline before actually closing the channel

Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
@toddbaert
toddbaert requested a review from a team as a code owner September 11, 2026 16:58
@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 3f3151c7-01a0-48d0-a263-42d83fd3a99d

📥 Commits

Reviewing files that changed from the base of the PR and between d69584b and 2fe8751.

📒 Files selected for processing (3)
  • providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/process/storage/connector/sync/SyncStreamQueueSource.java
  • providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/rpc/RpcResolver.java
  • providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/resolver/process/storage/connector/sync/SyncStreamQueueSourceTest.java

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


📝 Walkthrough

Walkthrough

The shutdown methods now close channel connectors before awaiting retry scheduler termination. A regression test verifies that an active sync stream cancels and shutdown completes within the configured timeout.

Changes

Shutdown ordering

Layer / File(s) Summary
Reorder shutdown operations
providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/process/storage/connector/sync/SyncStreamQueueSource.java, providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/rpc/RpcResolver.java
Both shutdown methods close the channel connector before awaiting retry scheduler termination.
Validate bounded shutdown
providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/resolver/process/storage/connector/sync/SyncStreamQueueSourceTest.java
The test verifies active stream cancellation, connector shutdown, and completion before the configured timeout.

Priority: ⬇️ Low

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

Change: Bug fix

Suggested reviewers: aepfli

Merge Risk: ⚪ Minimal · up to 2fe87

Shutdown now completes promptly for active streams, with regression coverage for the ordering fix.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the shutdown blocking issue related to the unary RPC deadline. It summarizes the main change, although the wording is slightly awkward.
Description check ✅ Passed The description directly explains the incorrect shutdown order and the fix: close the channel before awaiting termination. It is clearly related to the changeset.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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

Comment on lines 176 to -179
retryScheduler.shutdownNow();
// shut the channel down before awaiting
grpcComponents.channelConnector.shutdown();
ShutdownUtils.awaitTerminationQuietly(
() -> retryScheduler.awaitTermination(deadline, TimeUnit.MILLISECONDS));
grpcComponents.channelConnector.shutdown();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This ordering is wrong - we wait first, and then shutdown (this was due to a refactor which didn't correctly re-order these).

Obviously, we need to shut down the channel and then wait.

verify(stub, times(2)).syncFlags(any(), any());
}

@Test

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This test fails without the fix. I also verified the bug and fix manually.

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.

5 participants