-
Notifications
You must be signed in to change notification settings - Fork 140
[4.0.3 backport] CBG-4934 restart db initialization if needed #7982
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
base: release/4.0.3
Are you sure you want to change the base?
Conversation
cherry-pick of 068c0e7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR backports changes from commit 068c0e7 to enable restarting database initialization when needed. The primary focus is on improving cancellation handling for database initialization by adding context causes and updating the RemoveDatabase method signature to include a reason parameter.
Changes:
- Added
reasonparameter toRemoveDatabaseandCancelmethods for better traceability of why database operations are being stopped - Switched from
context.WithCanceltocontext.WithCancelCauseto preserve cancellation reasons - Fixed test logic and race condition handling using atomic operations
- Enhanced error handling in
RetryLoopto properly propagate context causes
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| rest/database_init_manager.go | Core changes to support cancellation with cause, added logic to restart initialization if cancelled |
| rest/server_context.go | Updated RemoveDatabase signature to accept reason parameter |
| rest/admin_api.go | Updated calls to Cancel and RemoveDatabase with descriptive reasons |
| rest/api.go | Updated RemoveDatabase calls with context about the calling endpoint |
| rest/server_context_test.go | Updated test to pass reason parameter |
| rest/replicatortest/replicator_test.go | Updated test calls with descriptive reasons |
| rest/indextest/index_init_api_test.go | Enhanced test assertions and error checking |
| rest/database_init_manager_test.go | Fixed test expectations to handle restarted initialization, converted to atomic operations |
| base/util.go | Updated RetryLoop to use context.Cause for better error reporting |
| base/util_test.go | Added test for context cancellation with cause |
| case err := <-doneChan: | ||
| require.NoError(t, err) | ||
| case <-time.After(30 * time.Second): | ||
| require.Fail(t, "InitializeDatabase didn't complete in 10s") |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message still references '10s' but the timeout was increased to 30 seconds on line 57. Update the message to '30s' for consistency.
| require.Fail(t, "InitializeDatabase didn't complete in 10s") | |
| require.Fail(t, "InitializeDatabase didn't complete in 30s") |
| } | ||
|
|
||
| // Initializes the database. Will establish a new cluster connection using the provided server config. Establishes a new | ||
| // InitializeDatabase will establish a new cluster connection using the provided server config. Establishes a new |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment has inconsistent sentence structure. The first sentence is complete, but the second sentence fragment 'Establishes a new...' should be combined with the first or made into a complete sentence.
| // InitializeDatabase will establish a new cluster connection using the provided server config. Establishes a new | |
| // InitializeDatabase establishes a new cluster connection using the provided server config and creates a |
[4.0.3 backport] CBG-4934 restart db initialization if needed
cherry-pick of 068c0e7