Skip to content

Conversation

@casperisfine
Copy link
Contributor

Using a trology connection in a concurrent way will likely lead to various protocol errors, but can also lead to various crashes.

As such it is preferable if Trilogy raises a clear to understand and deterministic error.

I chose to implement this on the Ruby side, because it's simpler and more straightforward.

I initially tried to do it in C, but the _cb_wait callback may raise or throw, so we'd need to use rb_protect, and release the lock there. The problem is the callback doesn't have access to the trilogy_context struct, so can't release the lock.

If we're adament this should be done in C, we'll need a much larger refactor.

cc @tenderlove @jhawthorn

Using a trology connection in a concurrent way will likely
lead to various protocol errors, but can also lead to various
crashes.

As such it is preferable if Trilogy raises a clear to understand
and deterministic error.

I chose to implement this on the Ruby side, because it's simpler and
more straightforward.

I initially tried to do it in C, but the `_cb_wait` callback may
raise or throw, so we'd need to use `rb_protect`, and release the lock
there. The problem is the callback doesn't have access to the
`trilogy_context` struct, so can't release the lock.

If we're adament this should be done in C, we'll need a much larger
refactor.
@samuel-williams-shopify
Copy link

This makes sense to me! Nice work. I don't have a strong opinion about the implementation, but this is better than crashing for sure.

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.

3 participants