Closes #2374: Deadlock when creating HistoryEvents from many connecti… #2424
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…ons simultaneously
-Write operations are now performed with the regular TaskanEngine and its' SqlSession and TransactionFactory which provides the needed transactionality and doesn't open multiple connections -Read operations are still performed by the TaskanaHistoryEngine
Some additional info on this PR:
for this new check in the TaskanaEngineImpl:
if (transactionFactory.getClass().getSimpleName().equals("SpringManagedTransactionFactory")) {
sessionManager.startManagedSession();
}
SONAR would like to use "instanceof" instead of comparing the class name with a String. Problem is, that we have no dependency at this point in the core, so the SpringManagedTransactionFactory.class is not known
The JobScheduler gets initialized in the TaskanaEngineImpl. Unfortunately, it currently creates its' own TaskanaEngineImpl:
if (this.taskanaConfiguration.isJobSchedulerEnabled()) {
TaskanaConfiguration configuration =
new TaskanaConfiguration.Builder(this.taskanaConfiguration)
.jobSchedulerEnabled(false)
.build();
TaskanaEngine taskanaEngine =
TaskanaEngine.buildTaskanaEngine(configuration, EXPLICIT, transactionFactory);
Issue: The HistoryEventManager (and all other SPis) initialization logic follows at the end of the TaskanaEngineImpl constructor. Therefore the initialize() will get called twice and therefore we need the if checks when adding the mappers in the new initialization logic of the SimpleHistoryServiceImpl, e.g.:
if (!sqlSession
.getConfiguration()
.getMapperRegistry()
.hasMapper(TaskHistoryEventMapper.class)) {
sqlSession.getConfiguration().addMapper(TaskHistoryEventMapper.class);
}
Release Notes:
For the submitter:
Verified by the reviewer: