{"record":{"id":"bab0579f32203ca8","repo":"SonarSource/sonarqube","slug":"event-export-failed-after-processing-d-events-suc","errorCode":null,"errorMessage":"Event Export failed after processing %d events successfully","messagePattern":"Event Export failed after processing (.+?) events successfully","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/steps/ExportEventsStep.java","lineNumber":78,"sourceCode":"  @Override\n  public void execute(Context context) {\n    long count = 0L;\n    try (\n      StreamWriter<ProjectDump.Event> output = dumpWriter.newStreamWriter(DumpElement.EVENTS);\n      DbSession dbSession = dbClient.openSession(false);\n      PreparedStatement stmt = buildSelectStatement(dbSession);\n      ResultSet rs = stmt.executeQuery()) {\n\n      ProjectDump.Event.Builder builder = ProjectDump.Event.newBuilder();\n      while (rs.next()) {\n        ProjectDump.Event event = convertToEvent(rs, builder);\n        output.write(event);\n        count++;\n      }\n      LoggerFactory.getLogger(getClass()).debug(\"{} events exported\", count);\n\n    } catch (Exception e) {\n      throw new IllegalStateException(format(\"Event Export failed after processing %d events successfully\", count), e);\n    }\n  }\n\n  private PreparedStatement buildSelectStatement(DbSession dbSession) throws SQLException {\n    PreparedStatement stmt = dbClient.getMyBatis().newScrollingSelectStatement(dbSession, QUERY);\n    try {\n      stmt.setString(1, projectHolder.projectDto().getUuid());\n      stmt.setBoolean(2, true);\n      stmt.setString(3, SnapshotDto.STATUS_PROCESSED);\n      stmt.setBoolean(4, true);\n      return stmt;\n    } catch (Exception e) {\n      DatabaseUtils.closeQuietly(stmt);\n      throw e;\n    }\n  }\n\n  private ProjectDump.Event convertToEvent(ResultSet rs, ProjectDump.Event.Builder builder) throws SQLException {","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/steps/ExportEventsStep.java#L60-L96","documentation":"ExportEventsStep scrolls project events from the database and streams them into the dump. Any exception during the scroll/write loop is wrapped in an IllegalStateException reporting how many events were exported successfully before the failure. The resulting dump is incomplete and the export task fails.","triggerScenarios":"SQLException from the scrolling select of EVENTS rows, a ResultSet conversion failure in the event mapping, or an IOException writing the protobuf event to the StreamWriter, after `count` events were written.","commonSituations":"DB connection drop/timeout during a long scroll; corrupt EVENTS rows (e.g. null fields) failing conversion; dump filesystem full mid-export.","solutions":["Inspect the cause chain to distinguish DB errors from IO write errors","Check database health/connection pool settings for long-running scroll queries","Look for EVENTS rows for the project with null/invalid columns that break conversion","Ensure disk space on the dump volume, then rerun the export"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"try (PreparedStatement probe = db.newScrollingSelectStatement(dbSession, QUERY)) { probe.executeQuery().close(); } // fail fast on DB issues before export","typeGuard":null,"tryCatchPattern":"try { exportEventsStep.execute(); } catch (IllegalStateException e) { logger.error(\"Event export failed after N events: {}\", e.getCause(), e); markDumpInvalid(); }","preventionTips":["Increase DB statement/scroll timeouts for long exports","Monitor DB connection stability during export windows","Validate EVENTS rows for null required columns before export"],"tags":["sonarqube","project-export","events","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"}