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

[jdbc-driver] Synchronize access to the handlers map #93

Merged

Conversation

guilgaly
Copy link
Contributor

@guilgaly guilgaly commented Dec 2, 2018

This does seem to solve the intermittent test failures in https://github.com/zengularity/query-monad as we discussed.

Copy link
Owner

@cchantep cchantep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx. What's the test failing w/o? To possibly add a unit test there?

@guilgaly
Copy link
Contributor Author

guilgaly commented Dec 3, 2018

I'll see about adding a unit test, shouldn't be too hard.

In query-monad, the issue can occasionally happen in any one of the tests in WithPlayTransactionSpec. The handler registration is executed on the current thread, and the JDBC query execution happens on a different thread which may or may not yet see the previous mutation of the handlers map.

@guilgaly guilgaly force-pushed the jdbc-driver-handlers-thread-safety branch from 7c498f2 to 023a498 Compare December 5, 2018 13:54
@guilgaly
Copy link
Contributor Author

guilgaly commented Dec 5, 2018

I added a simple test which basically just reproduces the same situation we have with the problematic query-monad test, except with many iterations. When executed a few times on my computer, it did consistently fail with the non-synchronized HashMap and succeed with the synchronizedMap.

@guilgaly guilgaly force-pushed the jdbc-driver-handlers-thread-safety branch from 023a498 to 8b26358 Compare December 5, 2018 14:08
@cchantep cchantep merged commit a383dff into cchantep:master Dec 6, 2018
@guilgaly guilgaly deleted the jdbc-driver-handlers-thread-safety branch January 21, 2019 16:16
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.

2 participants