diff options
author | David Gageot <david@gageot.net> | 2012-10-06 09:15:27 +0200 |
---|---|---|
committer | David Gageot <david@gageot.net> | 2012-10-06 09:15:27 +0200 |
commit | 8129e3c32539ebba359933d255190e765afe3ac7 (patch) | |
tree | 28bc0b230ef98fa1b7402040e0651a5bfa35cbf1 /sonar-core | |
parent | 71f3fd6c8a49c80f4183106f85a018668774d097 (diff) | |
download | sonarqube-8129e3c32539ebba359933d255190e765afe3ac7.tar.gz sonarqube-8129e3c32539ebba359933d255190e765afe3ac7.zip |
SONAR-3641 Fix DBCleaner when there are 2000+ characteristics
Diffstat (limited to 'sonar-core')
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java index 7e670362182..9d3b77a486a 100644 --- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java +++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java @@ -20,11 +20,14 @@ package org.sonar.core.purge; import com.google.common.annotations.VisibleForTesting; +import com.google.common.collect.Iterables; import org.apache.ibatis.session.SqlSession; import java.util.List; class PurgeCommands { + private static final int MAX_CHARACTERISTICS_PER_QUERY = 1000; + private final SqlSession session; private final PurgeMapper purgeMapper; @@ -203,7 +206,10 @@ class PurgeCommands { List<Long> characteristicIds = purgeMapper.selectCharacteristicIdsToPurge(); if (!characteristicIds.isEmpty()) { for (Long snapshotId : snapshotIds) { - purgeMapper.deleteSnapshotMeasuresOnCharacteristics(snapshotId, characteristicIds); + // SONAR-3641 We cannot process all characteristics at once + for (List<Long> ids : Iterables.partition(characteristicIds, MAX_CHARACTERISTICS_PER_QUERY)) { + purgeMapper.deleteSnapshotMeasuresOnCharacteristics(snapshotId, ids); + } } session.commit(); } |