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 panic for double unlock for unexpected method calls #216

Merged
merged 2 commits into from
Aug 12, 2024

Conversation

StevenACoffman
Copy link
Contributor

This PR avoids many double mutex unlock panics for unexpected calls to methods.

When the call to method was not expected, prior to this PR, pgxmock would not send the proper message back, but would instead panic without giving any message as to what the problem was.

Signed-off-by: Steve Coffman <steve@khanacademy.org>
@pashagolub
Copy link
Owner

Cool! Thanks! Would you please add a test case checking the bug. Thanks

@svennis94
Copy link
Contributor

We have experienced similar behavior, specifically when running with MatchExpectationsInOrder set to false. We have a wait group that executes a couple of queries in parallel with go routines. So the order of queries is unknown, 70% of times the test succeed and the other 30% it gives the error fatal error: sync: unlock of unlocked mutex from the pgxmock package.

We have tested this change and this does tackle the panic, and since all expectations are met due to the MatchExpectationsInOrder there are no unmet expectations so the tests pass 100% of the time. It is however a hard testcase to write from our use case 😅, since it doesn't fail all of the time.

+1 from us!

@pashagolub pashagolub self-assigned this Aug 12, 2024
@pashagolub pashagolub added the bug Something isn't working label Aug 12, 2024
@pashagolub pashagolub changed the title Avoid panic for double unlock for unexpected method calls [-] fix panic for double unlock for unexpected method calls Aug 12, 2024
@pashagolub pashagolub merged commit a3a041d into pashagolub:master Aug 12, 2024
3 of 4 checks passed
@StevenACoffman
Copy link
Contributor Author

Thanks so much for merging! I was trying to circle back to write the tests, but mine were going to be way over complicated. :)

@pashagolub
Copy link
Owner

Yeah, this one #217 was tricky to catch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants