Skip to content

fix: deadlock if /change is called during /restart#321

Merged
toddbaert merged 1 commit intomainfrom
fix/deadlock-on-change-while-restarting
Jan 6, 2026
Merged

fix: deadlock if /change is called during /restart#321
toddbaert merged 1 commit intomainfrom
fix/deadlock-on-change-while-restarting

Conversation

@toddbaert
Copy link
Member

If the /change endpoint was called while flagd was restarting (due to the /restart endpoint) the filewatcher was closed (because the allFlags.json was deleted). Due to this, the waitgroup never stopped waiting.

In the Java e2e suite, it looks like this:

Error:  Failures: 
Error:    RunRpcTest.Flag change event 1 expectation failed.
Expected status code <200> but was <500>.

Error:    RunRpcTest.Flag change event with caching 1 expectation failed.
Expected status code <200> but was <500>.

Error:    RunRpcTest.Use enriched context on RPC connection will not cache the value 1 expectation failed.
Expected status code <200> but was <500>.

https://github.com/open-feature/java-sdk-contrib/actions/runs/20754500347/job/59592648835?pr=1624

This change removes the PauseFileWatcher and ContinueFileWatcher funcs, and instead just allows to the filewatcher to be safely restarted, preventing this deadlock. I ran this against the Java suite locally and it fixed the intermittent failure caused by the deadlock

@toddbaert toddbaert requested a review from a team as a code owner January 6, 2026 16:32
@gemini-code-assist
Copy link

Summary of Changes

Hello @toddbaert, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical deadlock scenario that could arise from the interaction between flag change operations and system restarts. By refactoring the file watcher mechanism to allow for a safe and controlled restart, the changes eliminate a race condition where the file watcher's waitgroup would never complete. This significantly enhances the system's robustness and prevents service disruptions during dynamic configuration updates.

Highlights

  • Deadlock Fix: Addresses a deadlock condition that occurred when the /change endpoint was called during a /restart operation, specifically when the filewatcher was closed prematurely.
  • File Watcher Refactor: Removes the PauseFileWatcher and ContinueFileWatcher functions, replacing them with a single RestartFileWatcher function that safely closes and reinitializes the file watcher.
  • Improved Stability: Prevents intermittent 500 errors observed in the Java e2e suite, ensuring the system remains responsive during concurrent flag changes and restarts.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@toddbaert toddbaert force-pushed the fix/deadlock-on-change-while-restarting branch from 4957628 to f26749f Compare January 6, 2026 16:33
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a deadlock issue by replacing the pause/continue logic for the file watcher with a more robust restart mechanism. This is a solid approach to fixing the underlying problem. However, the new implementation introduces a couple of issues: a potential data race in RestartFileWatcher and an ignored error return value. My review includes suggestions to resolve these concerns.

Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
@toddbaert toddbaert force-pushed the fix/deadlock-on-change-while-restarting branch from f26749f to 490239a Compare January 6, 2026 16:42
@toddbaert toddbaert merged commit 4583da2 into main Jan 6, 2026
3 checks passed
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