From: Claire Villard Date: Thu, 10 Oct 2024 08:14:31 +0000 (+0200) Subject: SONAR-23350 Fix ORA-1000 Maximum Number of Cursors Exceeded during measures migration X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=598bdb410359f5bc198652b6dc802d0b1e2f8758;p=sonarqube.git SONAR-23350 Fix ORA-1000 Maximum Number of Cursors Exceeded during measures migration --- diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v108/AbstractMigrateLiveMeasuresToMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v108/AbstractMigrateLiveMeasuresToMeasures.java index 307d5750710..1c79d917294 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v108/AbstractMigrateLiveMeasuresToMeasures.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v108/AbstractMigrateLiveMeasuresToMeasures.java @@ -77,25 +77,25 @@ public abstract class AbstractMigrateLiveMeasuresToMeasures extends DataChange { private String getSelectUuidQuery() { return format(""" - SELECT uuid - FROM %s - WHERE measures_migrated = ? - """, tableName); + SELECT uuid + FROM %s + WHERE measures_migrated = ? + """, tableName); } private String getCountQuery() { return format(""" - SELECT count(uuid) - FROM %s - """, tableName); + SELECT count(uuid) + FROM %s + """, tableName); } private String getUpdateFlagQuery() { return format(""" - UPDATE %s - SET measures_migrated = ? - WHERE uuid = ? - """, tableName); + UPDATE %s + SET measures_migrated = ? + WHERE uuid = ? + """, tableName); } @Override @@ -149,20 +149,23 @@ public abstract class AbstractMigrateLiveMeasuresToMeasures extends DataChange { }); // insert the last component if (!measureValues.isEmpty()) { - Upsert measureInsert = context.prepareUpsert(INSERT_QUERY); - preparePersistMeasure(uuid, measureInsert, componentUuid, measureValues); - measureInsert - .execute() - .commit(); + try (Upsert measureInsert = context.prepareUpsert(INSERT_QUERY)) { + preparePersistMeasure(uuid, measureInsert, componentUuid, measureValues); + measureInsert + .execute() + .commit(); + } } LOGGER.debug("Flagging migration done for {} {}...", item, uuid); - context.prepareUpsert(getUpdateFlagQuery()) - .setBoolean(1, true) - .setString(2, uuid) - .execute() - .commit(); + try (Upsert flagUpdate = context.prepareUpsert(getUpdateFlagQuery())) { + flagUpdate + .setBoolean(1, true) + .setString(2, uuid) + .execute() + .commit(); + } LOGGER.debug("Migration finished for {} {}", item, uuid); }