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
Addressing some thread safety concerns. #81
Conversation
pnomolos
commented
Sep 21, 2016
- Fixed the spec so it's properly multi-threaded. Previously the threads were being joined in the loop, so they were executing in serial.
- Changed the default pool size to 20 so the threaded tests can run
- Snychronized access to running the row function (so functions aren't simultaneously created)
- Synchronized access to the row function cache
- May fix PostgreSQL error » duplicate key value violates unique constraint "pg_proc_proname_args_nsp_index" #72 - given that threading leads to random errors, it may or may not be the case.
- Fixed the spec so it's properly multi-threaded. Previously the threads were being joined in the loop, so they were executing in serial. - Changed the default pool size to 20 so the threaded tests can run - Snychronized access to running the row function (so functions aren't simultaneously created) - Synchronized access to the row function cache
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we try with only the test fix and not any code fixes?
in other words, i know you found a problem with the tests, but i'm not convinced that you need to add mutexes to row
method ... so i want to try without
end | ||
ts.each { |t| t.join } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow that is a huge error!
row_object = Row.new(selector, setter, options) | ||
merge_function(row_object).execute(row_object) | ||
nil | ||
@row_mutex ||= Mutex.new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
creating a Mutex with ||=
is itself a thread safety concern!
Move mutex definitions to initializer as `||=` is not thread safe Temporarily disable `synchronize` calls.
@seamusabshere The build is now broken ;) I'm seeing all sorts of weird stuff locally, the most common being: |
@seamusabshere Yeah, that sounds like a good idea. |
@seamusabshere You OK if I uncomment the mutexes now? ;) |
@seamusabshere I re-added the fixes and we're passing again. I do believe we need the mutexes. |
@seamusabshere Mind re-reviewing this? :) |
@pnomolos looks good! |