-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: prevent badgerdb hang when closing without prior operations #5074
Conversation
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
41ff97b
to
14e8452
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5074 +/- ##
==========================================
- Coverage 74.68% 74.63% -0.06%
==========================================
Files 435 435
Lines 50363 50369 +6
==========================================
- Hits 37616 37594 -22
- Misses 10270 10289 +19
- Partials 2477 2486 +9 ☔ View full report in Codecov by Sentry. |
Description
Issue
When transitioning a newly created rudder-server instance that has received no traffic from normal to degraded mode, the process hangs. Causing migration to stuck as well, until instance is restarted, upon restart no transition is required, as rudder-server starts on degrade mode.
Taking a goroutine dump:
You can see that badger.Close hangs, preventing the shutdown to be completed.
I was able to replicate this locally, using the following test:
Root-cause
Close was waiting for
d.gcDone
to close, but this will never happen, becauseinit
was never called.Solution
Naive approach is to ensure init is called at the start of close method. However, this is counter intuitive, and also handling error for init would be needed. Also, in case init error, gc loop go routine won't be call as well.
A safer approach is to introduce a waitgroup, that tracks for any pending background go routines, and won't block if non have been started.
Also,
bgCtx
is introduced as a more conventional wait to pass termination.Linear Ticket
https://linear.app/rudderstack/issue/PIPE-1420/rudder-server-did-not-transition-to-degraded-mode
resolves PIPE-1420
Security