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

Integration tests fail when using multiple datasources #9068

Closed
roadrunner2 opened this issue Jul 1, 2015 · 1 comment
Closed

Integration tests fail when using multiple datasources #9068

roadrunner2 opened this issue Jul 1, 2015 · 1 comment

Comments

@roadrunner2
Copy link

When using multiple datasources, integration tests using transactions in the setupSpec will fail with an UnexpectedRollbackException. A minimal sample project is available at https://gist.github.com/d2e416f2539f51945b1d.git (base64decode and unzip - if there's a better way "attach" things, let me know).

I've debugged this and found the cause for it. In GrailsTestTransactionInterceptor it builds up a list of transaction-managers, and then calls rollback on each one at the end of the test. The problem now stems from the fact that the default dataSource's transaction-manager is actually a ChainedTransactionManager, which means that in destroy() it ends up doing a rollback twice on the second datasource's transaction-manager (first indirectly via the ChainedTransactionManager, and then again via a direct call in GrailsTestTransactionInterceptor.destroy()).

I'm not sure of the correct fix, but just not adding the non-default datasources to the transactionManagers (e.g. by commenting out the lines 49 - 53) does solve the problem in this instance.

This was encountered and debugged on grails 2.5.0.

@graemerocher
Copy link
Member

@lhotari Do you know the correct way to handle this given your experience of ChainedTransactionManager

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants