Skip to content

Conversation

@torcolvin
Copy link
Collaborator

@torcolvin torcolvin commented Oct 14, 2025

If DatabaseInitManager is in the process of exiting due to context cancellation, and then another initialization process starts, that initialization will not start new workers but pick up the old workers instead.

The fix is to check to see if the context is cancelled when deciding whether restart workers.

Added WithCancelCause for debugging purposes to see which context was cancelled. The actual cancellation errors will appear in a RetryLoop for creating indexes.

Integration Tests

If DatabaseInitManager is in the process of exiting due to context cancellation, and then another initialization process
starts, that initialization will not start new workers but pick up the
old workers instead.

The fix is to check to see if the context is cancelled when deciding
whether restart workers.

Added WithCancelCause for debugging purposes to see which context was
cancelled. The actual cancellation errors will appear in a RetryLoop
for creating indexes.
@Copilot Copilot AI review requested due to automatic review settings October 14, 2025 16:58
Copy link
Contributor

Copilot AI left a 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 addresses an issue where the DatabaseInitManager could pick up old, cancelled workers instead of starting new ones when database initialization is restarted. The fix involves checking if the worker's context is cancelled before reusing it and adding reason tracking for cancellation events.

  • Adds context cancellation checking to prevent reusing shutdown workers
  • Updates RemoveDatabase to accept a cancellation reason parameter
  • Enhances error reporting for context cancellation with cause tracking

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
rest/database_init_manager.go Core fix: checks worker context cancellation before reuse and adds WithCancelCause support
rest/server_context.go Updates RemoveDatabase signature to include reason parameter
rest/api.go Updates RemoveDatabase calls with URL-based reasons
rest/admin_api.go Updates RemoveDatabase and Cancel calls with descriptive reasons
rest/server_context_test.go Updates test to use new RemoveDatabase signature
rest/replicatortest/replicator_test.go Updates RemoveDatabase calls with test context descriptions
rest/indextest/index_init_api_test.go Improves test assertions for better debugging
base/util.go Updates RetryLoop to use context.Cause for better error reporting
base/util_test.go Adds test coverage for context cancellation with cause

@torcolvin torcolvin merged commit 068c0e7 into main Oct 22, 2025
89 of 93 checks passed
@torcolvin torcolvin deleted the CBG-4677 branch October 22, 2025 13:42
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.

2 participants