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

Use with_connection instead of calling release_connection directly #320

Closed
wants to merge 2 commits into from
Closed

Conversation

jmarianer
Copy link

The call to release_connection, added in #263, might release a connection that was opened outside of has_closure_tree (if the caller is loaded dynamically in the middle of some other operation). This is especially problematic if the connection has an ongoing transaction, as that transaction will be lost.

This PR changes has_closure_tree to use with_connection instead, which only releases a connection if it was acquired. If a connection already existed prior to the call to has_closure_tree, it won't be released.

Joey Marianer added 2 commits July 31, 2018 15:50
…ince the latter may release a connection that belongs to someone else
@jmarianer
Copy link
Author

FYI, I think the Travis failure is just some intermittent errors on their end, but I can't retrigger the build myself.

@n-rodriguez
Copy link
Contributor

Seems good to me

:with_advisory_lock
)
connection_pool.with_connection {
options.assert_valid_keys(
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe the check could happen before (or outside) the connection_pool.with_connection block to avoid useless connections?

@seuros
Copy link
Member

seuros commented Aug 27, 2018

We need to check that the code won't break with Databaseless setup.

@jmarianer
Copy link
Author

Just got back from vacation.
@seuros, could you explain what that means? I'm happy to add a test but I've never not used a database.
@n-rodriguez I'll move the validation outside the block as part of my next push.
Thanks!

@jmarianer
Copy link
Author

I moved this project to the instructure-bridge organization (aka my employer) as #340 and will close this one.

@jmarianer jmarianer closed this Dec 21, 2018
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