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

Resolve potential race in resume/reconnect #365

Merged
merged 2 commits into from Oct 24, 2019
Merged

Resolve potential race in resume/reconnect #365

merged 2 commits into from Oct 24, 2019

Conversation

MattBrittan
Copy link
Contributor

If resume continued to run through a disconnect/reconnect
cycle then a race would be caused by c.stop = make(chan struct{})
Likely to be a rare issue in production (a lot of messages persisted,
slow store, and/or fast reconnect).
Also to enable tests to be run with the race detector
Test_ConnectRetry has been updated to avoid a race.

Probably closes #362 (cannot be sure becasue issue does ont provide sufficient detail)

Signed-off-by: Matt Brittan matt@brittan.nz

If resume continued to run through a disconnect/reconnect
cycle then a race would be caused by c.stop = make(chan struct{})
Likely to be a rare issue in production (a lot of messages persisted,
slow store, and/or fast reconnect).
Also to enable tests to be run with the race detector the
Test_ConnectRetry has been updated to avoid a race.

Signed-off-by: Matt Brittan <matt@brittan.nz>
The initil implementation of this made client.go more
confusing than was required (as the change was just
to support testing). Added a mutex to support this as
that approach might be useful with other tests too.

Signed-off-by: Matt Brittan <matt@brittan.nz>
@MattBrittan
Copy link
Contributor Author

My original changes to remove the race in Test_ConnectRetry added complexity to client.go (and was a bit ugly). I have changed this to use a mutex instead as I think its easier to follow.

@alsm
Copy link
Contributor

alsm commented Oct 24, 2019

That's definitely better, thanks

@alsm alsm merged commit 962bb61 into eclipse:master Oct 24, 2019
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.

Detect race condition!!!
2 participants