Skip to content

Commit

Permalink
0001614: Parallelize the synchronization of triggers to improve
Browse files Browse the repository at this point in the history
performance in a system with lots of tables
  • Loading branch information
erilong committed Jun 28, 2016
1 parent 7268921 commit 1699ec7
Showing 1 changed file with 11 additions and 7 deletions.
Expand Up @@ -324,12 +324,14 @@ public Map<Long, TriggerHistory> getHistoryRecords() {
}

protected boolean isTriggerNameInUse(List<TriggerHistory> activeTriggerHistories, String triggerId, String triggerName) {
for (TriggerHistory triggerHistory : activeTriggerHistories) {
if (!triggerHistory.getTriggerId().equals(triggerId) && (
(triggerHistory.getNameForDeleteTrigger() != null && triggerHistory.getNameForDeleteTrigger().equals(triggerName)) ||
(triggerHistory.getNameForInsertTrigger() != null && triggerHistory.getNameForInsertTrigger().equals(triggerName)) ||
(triggerHistory.getNameForUpdateTrigger() != null && triggerHistory.getNameForUpdateTrigger().equals(triggerName)))) {
return true;
synchronized (activeTriggerHistories) {
for (TriggerHistory triggerHistory : activeTriggerHistories) {
if (!triggerHistory.getTriggerId().equals(triggerId) && (
(triggerHistory.getNameForDeleteTrigger() != null && triggerHistory.getNameForDeleteTrigger().equals(triggerName)) ||
(triggerHistory.getNameForInsertTrigger() != null && triggerHistory.getNameForInsertTrigger().equals(triggerName)) ||
(triggerHistory.getNameForUpdateTrigger() != null && triggerHistory.getNameForUpdateTrigger().equals(triggerName)))) {
return true;
}
}
}
return false;
Expand Down Expand Up @@ -1648,7 +1650,9 @@ protected void updateOrCreateDatabaseTriggers(Trigger trigger, Table table,
}

if (newestHistory != null) {
activeTriggerHistories.add(newestHistory);
synchronized (activeTriggerHistories) {
activeTriggerHistories.add(newestHistory);
}
newestHistory.setErrorMessage(errorMessage);
if (parameterService.is(ParameterConstants.AUTO_SYNC_TRIGGERS)) {
for (ITriggerCreationListener l : extensionService.getExtensionPointList(ITriggerCreationListener.class)) {
Expand Down

0 comments on commit 1699ec7

Please sign in to comment.