-
Notifications
You must be signed in to change notification settings - Fork 140
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
Use correct mutex to guard confirms.published #240
Use correct mutex to guard confirms.published #240
Conversation
I have added a test which, if run without the fix, results in data race warning:
With the fix, there is no data race.
|
Thank you very much! If you have time to review the use of these and other mutexes for similar errors, we would appreciate it. Obviously, this is a subtle bug 😸 |
@lukebakken It was a subtle bug indeed. I came across it while investing an issue I am facing on production. The only clues I had were that the production bug started happening when I implemented Publisher Confirms and the code was publishing a lot of messages in bursts. I will keep an eye out for more. 🙂 |
ddb7218
to
977c4d2
Compare
Thank you for fixing this! I've approved the CI run and I'll merge after CI passes 👍 |
The
confirms
type uses thepublishedMut
to guard access to thepublished
field:amqp091-go/confirms.go
Lines 43 to 47 in a6fa7f7
amqp091-go/confirms.go
Lines 53 to 56 in a6fa7f7
etc.
However, the
Channel
type uses the mutexm
(on theconfirms
type) instead:amqp091-go/channel.go
Lines 1829 to 1832 in a6fa7f7
This can lead to race if the
GetNextPublishSeqNo
function is used while other functions on theconfirms
type is used concurrently.