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

Handle edge cases and support autocommit=false #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

luneo7
Copy link

@luneo7 luneo7 commented Oct 28, 2024

Handles #14

Only tries to disable autocommit if needed.

Also handles edge cases, we internally hit a bug in where in the catch block we were calling conn.setAutoCommit(true); and there it failed, so the finally block condition if (null != didWeStartWork.get() && conn.getAutoCommit()) { wasn't true, and that made the connection not get released back to the connection pool, since the connection is released only during the ending of the unit of work.

So I've simplified the logic to have everything in a try catch finally block and now we are always releasing the connection to the pool.

Improved the readTransactionMetadata cache, as there it is a concurrent hash map, so get doesn't block, so if it is a cache miss, concurrent calculations will use the compute if absent, which synchronizes the calls, so we don't perform multiple calculations for the same thing at once.

Reduced the number of thread locals, and fixed it as ideally it should be a static field.

Also fixed a possible leak as if closing a the connection were to throw an error the thread local wouldn't never be removed.

@luneo7 luneo7 force-pushed the master branch 2 times, most recently from 346f89a to 668d67d Compare October 28, 2024 21:28
@luneo7
Copy link
Author

luneo7 commented Oct 28, 2024

/cc @supercargo

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.

1 participant