Skip to content

Bug: Fix race condition, add reduce active worker when closing, add Once prevent double call Close channel#5

Merged
SangTran-127 merged 3 commits intomainfrom
fix/race-condition-metrics-worker-spawn
Feb 2, 2026
Merged

Bug: Fix race condition, add reduce active worker when closing, add Once prevent double call Close channel#5
SangTran-127 merged 3 commits intomainfrom
fix/race-condition-metrics-worker-spawn

Conversation

@SangTran-127
Copy link
Copy Markdown
Owner

No description provided.

Copy link
Copy Markdown

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 critical concurrency issues in the WorkerPool implementation by fixing a race condition in ActiveWorkers tracking, preventing double-close panics, and improving error messaging.

Key Changes:

  • Fixed race condition by tracking ActiveWorkers with atomic increment/decrement operations instead of bulk assignment
  • Added sync.Once protection to prevent panic from calling Stop() multiple times
  • Enhanced error message for full task queue to include pool name and capacity

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread workerpool/workerpool.go
Comment thread workerpool/workerpool.go
@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread workerpool/workerpool_test.go
@SangTran-127 SangTran-127 merged commit cec9da5 into main Feb 2, 2026
7 checks passed
@SangTran-127 SangTran-127 deleted the fix/race-condition-metrics-worker-spawn branch February 2, 2026 12:20
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.

3 participants