Race Condition Tool?


(Andy Jones) #1

It appears that Golang has Race Detector, a tool to detect race conditions -- https://blog.golang.org/race-detector

Does anyone know of anything similar for Ruby? Or, any advice at all for testing that my code is threadsafe?

(Detail: I'm writing a connection pool. This is for Ruby, not Rails. I think I have a workable approach, but I'm not sure how best to write the tests...)

Click here to view Company Information and Confidentiality Notice.<http://www.jameshall.co.uk/index.php/small-print/email-disclaimer>


(Jeremy Bopp) #2

Maybe you're doing this as a learning experience for yourself, but in case
you aren't, there's a gem that provides generic connection pooling:
https://rubygems.org/gems/connection_pool.

Unfortunately, I'm not aware of a race condition detector for Ruby.

···

On Thu, Apr 5, 2018 at 9:09 AM Andy Jones <Andy.Jones@jameshall.co.uk> wrote:

It appears that Golang has Race Detector, a tool to detect race conditions
-- https://blog.golang.org/race-detector

Does anyone know of anything similar for Ruby? Or, any advice at all for
testing that my code is threadsafe?

(Detail: I’m writing a connection pool. This is for Ruby, not Rails. I
think I have a workable approach, but I’m not sure how best to write the
tests…)

Click here to view Company Information and Confidentiality Notice.
<http://www.jameshall.co.uk/index.php/small-print/email-disclaimer>

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>

--

-Jeremy


(Andy Jones) #3

Maybe you're doing this as a learning experience for yourself, but in case you aren't, there's a gem that provides generic connection pooling: https://rubygems.org/gems/connection_pool.

Thanks, Jeremy. I’ve seen that, and using it is plan B. I’m trying not to add an extra dependency to a project that already has quite a few…

Click here to view Company Information and Confidentiality Notice.<http://www.jameshall.co.uk/index.php/small-print/email-disclaimer>


(Ryan Davis) #4

So you’re going to write your own? This is not the time to be shaving off a single dependency.

···

On Apr 5, 2018, at 07:39, Andy Jones <Andy.Jones@jameshall.co.uk> wrote:

Thanks, Jeremy. I’ve seen that, and using it is plan B. I’m trying not to add an extra dependency to a project that already has quite a few…


(Andy Jones) #5

So you’re going to write your own? This is not the time to be shaving off a single dependency.

(Apologies, I've been off for a few days.)

Well, this brings me back nicely to my question: if I could find a reliable way to test for race conditions, I'd know if my code was any good or not, and then be able to fall back to using that library if it wasn't...

I suspect that the concept of a "connection pool" comes with a lot of features implied in it, which I don't actually need. So it's not quite as bad as it seems. Also: this is for something somewhat like an ORM (but considerably simpler) so there is the school of thought that if I can’t understand how to write my own connection pool, I should just give up?

Click here to view Company Information and Confidentiality Notice.<http://www.jameshall.co.uk/index.php/small-print/email-disclaimer>