-
Notifications
You must be signed in to change notification settings - Fork 59
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
control-service: code expected to run in transaction now runs in transaction #2117
Conversation
Signed-off-by: murphp15 <[email protected]>
Signed-off-by: murphp15 <[email protected]>
for more information, see https://pre-commit.ci
Signed-off-by: murphp15 <[email protected]>
Signed-off-by: murphp15 <[email protected]>
Signed-off-by: murphp15 <[email protected]>
Signed-off-by: murphp15 <[email protected]>
Signed-off-by: murphp15 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did you verify that the method is now executed within a transaction ?
(could be by looking at logs by setting logging.level.org.springframework.transaction=debug; or debugger or best with unit tests).
@tozka |
Why
Often the test DataJobTerminationStatusIT fails with the following stacktrace.
I was looking into it and I realised the database operations were not actually taking place in a transaction despite the method being marked as transactional.
It is because calling a method from another method in a the same class stops spring from being able to intercept the function call and start a transaction.
Please see here for more details: https://stackoverflow.com/questions/3423972/spring-transaction-method-call-by-the-method-within-the-same-class-does-not-wo
What
In this PR I create a second class to call the transactional method so it can run in a transaction.
How was this tested
Locally, I was not able to reproduce the randomly failing test. But that is not to say I have 100% fixed it.
But this change is important because the code now does what the original author expected and will avoid cryptic bugs in the future.