{"record":{"id":"69af11df52ba3586","repo":"SonarSource/sonarqube","slug":"live-measure-export-failed-after-processing-d-mea","errorCode":null,"errorMessage":"Live Measure Export failed after processing %d measures successfully","messagePattern":"Live Measure Export failed after processing (.+?) measures successfully","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/steps/ExportLiveMeasuresStep.java","lineNumber":76,"sourceCode":"    try (\n      StreamWriter<LiveMeasure> output = dumpWriter.newStreamWriter(DumpElement.LIVE_MEASURES);\n      DbSession dbSession = dbClient.openSession(false);\n      PreparedStatement stmt = dbClient.getMyBatis().newScrollingSelectStatement(dbSession, QUERY)) {\n\n      stmt.setString(1, projectHolder.projectDto().getUuid());\n      stmt.setBoolean(2, true);\n      stmt.setBoolean(3, true);\n      try (ResultSet rs = stmt.executeQuery()) {\n        LiveMeasure.Builder liveMeasureBuilder = LiveMeasure.newBuilder();\n        while (rs.next()) {\n          LiveMeasure measure = convertToLiveMeasure(rs, liveMeasureBuilder);\n          output.write(measure);\n          count++;\n        }\n        LoggerFactory.getLogger(getClass()).debug(\"{} live measures exported\", count);\n      }\n    } catch (Exception e) {\n      throw new IllegalStateException(format(\"Live Measure Export failed after processing %d measures successfully\", count), e);\n    }\n  }\n\n  private LiveMeasure convertToLiveMeasure(ResultSet rs, LiveMeasure.Builder builder) throws SQLException {\n    builder\n      .clear()\n      .setComponentRef(componentRepository.getRef(rs.getString(1)))\n      .setJsonValue(rs.getString(2));\n    return builder.build();\n  }\n\n  @Override\n  public String getDescription() {\n    return \"Export live measures\";\n  }\n}\n","sourceCodeStart":58,"sourceCodeEnd":93,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/steps/ExportLiveMeasuresStep.java#L58-L93","documentation":"ExportLiveMeasuresStep scrolls live measures from the database and streams them as protobuf LiveMeasure messages into the dump. Any failure in the loop is rethrown as an IllegalStateException reporting the number of measures exported successfully. Like the other export steps, partial output means the whole dump is invalid.","triggerScenarios":"SQLException in the scrolling measure select or in convertToLiveMeasure() (ResultSet field conversion), or an IOException writing the protobuf message, after `count` measures were written.","commonSituations":"Very large measure volume causing long scrolls and DB timeouts; corrupt MEASURES rows with unexpected value formats; dump filesystem running out of space.","solutions":["Read the cause to identify whether the failure is SQL (query/timeout) or IO (stream write)","Tune DB scroll/statement timeouts for large projects with millions of measures","Validate MEASURES rows for the project for corrupt or null metric values","Ensure adequate disk space on the dump volume and rerun the export"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"long badMeasures = countMeasuresWithNullValue(projectUuid);\nif (badMeasures > 0) { logger.warn(\"{} live measures may fail conversion\", badMeasures); }","typeGuard":null,"tryCatchPattern":"try { exportLiveMeasuresStep.execute(); } catch (IllegalStateException e) { logger.error(\"Live measure export failed after N measures: {}\", e.getCause(), e); markDumpInvalid(); }","preventionTips":["Tune scroll timeouts for projects with very high measure counts","Check disk space before exporting large projects","Detect corrupt MEASURES rows (null metric/value) during maintenance"],"tags":["sonarqube","project-export","measures","database"],"backgroundTag":"database-query-failed","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}