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

Incorrect state for TransactionManager.manager after calling closeAndUnregister #1100

Closed
ZeDavi opened this issue Nov 24, 2020 · 2 comments
Closed

Comments

@ZeDavi
Copy link

ZeDavi commented Nov 24, 2020

Hi,

I found an unexpected behavior regarding the companion object in TransactionManager, that I think might be a bug.
How to reproduce:

  1. Call Database.connect(dataSource)
  2. Call transaction(db, statement) – this will result in the inTopLevelTransaction(...) function being called which ends with a TransactionManager.resetCurrent(null) call.
  3. Call TransactionManager.closeAndUnregister(database) (the one that was returned from step 1.)
  4. Call Database.connect(dataSource) a second time for a new dataSource

Now, TransactionManager.manager will return the initial NotInitializedManager instance, instead of the transaction manager that was created during step 4.

That is because inside the closeAndUnregister function in step 3., a value is removed from managers, afterwards the current transaction manager is calculated using managers.first which returns the bottom NotInitializedManager. Therefore currentThreadManager.remove() is not called and the current thread manager stays incorrect.

A workaround is calling TransactionManager.resetCurrent(null) right after step 3.

@RationalityFrontline
Copy link

Encountered same problem, thanks for the workaround, hope this simple issue could get fixed soon.

@Tapac
Copy link
Contributor

Tapac commented Jan 16, 2021

Fixed in master. Thanks for the report.

@Tapac Tapac closed this as completed Jan 16, 2021
Tapac added a commit that referenced this issue Jan 16, 2021
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

No branches or pull requests

3 participants