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

Addressing some thread safety concerns. #81

Merged
merged 6 commits into from Apr 4, 2018
Merged

Addressing some thread safety concerns. #81

merged 6 commits into from Apr 4, 2018

Conversation

pnomolos
Copy link
Collaborator

  • 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
Copy link
Owner

@seamusabshere seamusabshere left a 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 }
Copy link
Owner

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
Copy link
Owner

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.
@pnomolos
Copy link
Collaborator Author

pnomolos commented Sep 21, 2016

@seamusabshere The build is now broken ;) I'm seeing all sorts of weird stuff locally, the most common being: insufficient data in "T" message (I'm using postgresql)

@seamusabshere
Copy link
Owner

@pnomolos revisit once #79 is merged?

@pnomolos
Copy link
Collaborator Author

pnomolos commented Oct 7, 2016

@seamusabshere Yeah, that sounds like a good idea.

@pnomolos
Copy link
Collaborator Author

pnomolos commented Oct 7, 2016

@seamusabshere You OK if I uncomment the mutexes now? ;)

@pnomolos
Copy link
Collaborator Author

@seamusabshere I re-added the fixes and we're passing again. I do believe we need the mutexes.

@pnomolos
Copy link
Collaborator Author

pnomolos commented Apr 4, 2018

@seamusabshere Mind re-reviewing this? :)

@seamusabshere
Copy link
Owner

@pnomolos looks good!

@pnomolos pnomolos merged commit 3ac6ad2 into seamusabshere:master Apr 4, 2018
@pnomolos pnomolos deleted the thread_safety branch April 4, 2018 15:53
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.

PostgreSQL error » duplicate key value violates unique constraint "pg_proc_proname_args_nsp_index"
2 participants