fix: errors doesn't support concurrent#1370
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v1.17.x #1370 +/- ##
===========================================
- Coverage 68.66% 68.66% -0.01%
===========================================
Files 281 281
Lines 17698 17747 +49
===========================================
+ Hits 12153 12186 +33
- Misses 5043 5058 +15
- Partials 502 503 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Greptile Overview
Greptile Summary
Fixed concurrency issues in the errors package by making error objects immutable -
Args()andSetModule()now return new instances instead of mutating state.Args()andSetModule()methods to create newerrorStringinstances with copied fieldsIs()method for proper error comparison based on text contentqueue/worker.goto call.Error()on immutable error objectsConfidence Score: 5/5
Important Files Changed
Args()andSetModule()to return new instances instead of mutating state, addedIs()method for error comparisonSequence Diagram
sequenceDiagram participant Client participant ErrorBase as Base Error participant ErrorCopy1 as Error Copy 1 participant ErrorCopy2 as Error Copy 2 Note over Client,ErrorCopy2: Before (Mutable - Race Condition) Client->>ErrorBase: New("error: %s") Client->>ErrorBase: Args("value1") [mutates] Client->>ErrorBase: Args("value2") [mutates] Note over ErrorBase: Race condition!<br/>State corrupted Note over Client,ErrorCopy2: After (Immutable - Thread Safe) Client->>ErrorBase: New("error: %s") Client->>ErrorBase: Args("value1") ErrorBase->>ErrorCopy1: return new instance Client->>ErrorBase: Args("value2") ErrorBase->>ErrorCopy2: return new instance Note over ErrorBase,ErrorCopy2: Each goroutine has<br/>its own copy