Skip to content
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: BatchError.Add() non thread safe #3946

Merged
merged 2 commits into from
Mar 1, 2024

Conversation

ch3nnn
Copy link
Contributor

@ch3nnn ch3nnn commented Mar 1, 2024

BatchError.Add() non thread safe, append operation need locked.

help to review it. thank!

@kevwan @kesonan

@ch3nnn
Copy link
Contributor Author

ch3nnn commented Mar 1, 2024

example:

fx.Parallel(
	func() {
		_, err := l.svcCtx.xxxRpc.SelectXxx(l.ctx, &Req{})
		if err != nil {
			batchErr.Add(err)
		}
	},
	func() {
		_, err := l.svcCtx.xxxRpc.SelectXxx(l.ctx, &Req{})
		if err != nil {
			batchErr.Add(err)
		}
	},
        ...
        ...
        ...
	func() {
		_, err := l.svcCtx.xxxRpc.SelectXxx(l.ctx, &Req{})
		if err != nil {
			batchErr.Add(err)
		}
	},
)
	
if batchErr.NotNil() {
	return nil, batchErr.Err()
}

batchErr.Err() error message may be incomplete during concurrency

Copy link

codecov bot commented Mar 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.53%. Comparing base (5263805) to head (cd351dd).

Additional details and impacted files
Files Coverage Δ
core/errorx/batcherror.go 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

@kevwan kevwan added this pull request to the merge queue Mar 1, 2024
Merged via the queue into zeromicro:master with commit ec41880 Mar 1, 2024
6 checks passed
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.

None yet

2 participants