fix(net): stop BackupServer.close() hanging while bind is in flight - #150
fix(net): stop BackupServer.close() hanging while bind is in flight#150halibobo1205 wants to merge 1 commit into
Conversation
🤖 CodeAnt AI — Review Status
|
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f2cc4548a5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
f2cc454 to
a24a765
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a24a765e00
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (port > 0 && commonParameter.getBackupMembers().size() > 0) { | ||
| try { | ||
| // Let close() reach the group before bind() completes. | ||
| group = new NioEventLoopGroup(1); |
There was a problem hiding this comment.
Prevent startup from publishing resources after close
When close() races with this constructor before group is assigned, it observes both group and executor as null and returns; initServer() then publishes the group and submits start() to a new non-daemon executor. Since shutdown is already true, start() skips binding and returns after shutting down the group, but nothing ever shuts down the executor, leaving its worker alive and potentially preventing JVM termination. Coordinate initialization with close() or recheck shutdown before creating and submitting the executor.
Useful? React with 👍 / 👎.
Fix a shutdown race where close() runs before bind() publishes the channel, leaving the server thread blocked until the 60-second executor timeout. Create the event loop group in initServer() so close() can shut it down and interrupt pending waits.
a24a765 to
21076b1
Compare
User description
What does this PR do?
Fix a
BackupServershutdown race that can causeBackupServerTestto time out.Create the event loop group in
initServer()soclose()can shut it down even before thechannelis published, then interrupt pending waits and await server-thread termination.Why are these changes required?
Previously,
close()only closed an already-published channel. Ifbind()completed afterward, thechannelcould remain open and leave the server thread blocked incloseFuture().sync().Related CI failure: GitHub Actions job due to
The provided test log records executor shutdown before bind success is logged:
In the source,
BackupServer.java:80ischannel.closeFuture().sync().This PR has been tested by:
CodeAnt-AI Description
Prevent backup server shutdown from hanging during startup
What Changed
Impact
✅ Backup shutdown completes during startup✅ Fewer test and application shutdown timeouts✅ No lingering backup server background tasks💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.