SonarSource/sonarqube · critical · IllegalStateException
Analysis Export failed after processing %d analyses successf
Error message
Analysis Export failed after processing %d analyses successfully
What it means
ExportAnalysesStep.execute() scrolls all ANALYSES rows for the project and writes them to the dump output. Any exception during the streaming (SQL error, protobuf serialization failure, IO error on the output) is wrapped in an IllegalStateException that reports how many analyses were exported successfully before the failure, to aid resume/debug of the CE export task.
Source
Thrown at server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/analysis/ExportAnalysesStep.java:89
long count = 0L;
try (
StreamWriter<ProjectDump.Analysis> output = dumpWriter.newStreamWriter(DumpElement.ANALYSES);
DbSession dbSession = dbClient.openSession(false);
PreparedStatement stmt = buildSelectStatement(dbSession);
ResultSet rs = stmt.executeQuery()) {
ProjectDump.Analysis.Builder builder = ProjectDump.Analysis.newBuilder();
while (rs.next()) {
// Results are ordered by ascending id so that any parent is located
// before its children.
ProjectDump.Analysis analysis = convertToAnalysis(rs, builder);
output.write(analysis);
count++;
}
LoggerFactory.getLogger(getClass()).debug("{} analyses exported", count);
} catch (Exception e) {
throw new IllegalStateException(format("Analysis Export failed after processing %d analyses successfully", count), e);
}
}
private PreparedStatement buildSelectStatement(DbSession dbSession) throws SQLException {
PreparedStatement stmt = dbClient.getMyBatis().newScrollingSelectStatement(dbSession, QUERY);
try {
stmt.setString(1, projectHolder.projectDto().getUuid());
stmt.setBoolean(2, true);
stmt.setString(3, STATUS_PROCESSED);
stmt.setBoolean(4, true);
return stmt;
} catch (Exception t) {
DatabaseUtils.closeQuietly(stmt);
throw t;
}
}
private ProjectDump.Analysis convertToAnalysis(ResultSet rs, ProjectDump.Analysis.Builder builder) throws SQLException {View on GitHub (pinned to 184c821202)
Solutions
- Inspect the cause (getCause()) for the real failure — usually a SQLException — and fix the DB issue (connectivity, locks, missing column).
- Verify the sonarqube DB schema matches the running SonarQube version; run the upgrade/migration step if not.
- Check disk space and network to the dump destination; retry the CE task after fixing.
- Identify the problematic analysis row via the logged count and repair or remove the corrupt row.
Defensive patterns
Strategy: retry
Validate before calling
int analyses = dbClient.getPlatformDbClient().countAnalyses(projectUuid); // pre-check data access before export
Try / catch
try {
exportAnalysesStep.execute(context);
} catch (IllegalStateException e) {
logger.error("Analysis export failed after {}; cause: {}", parseCount(e.getMessage()), e.getCause(), e);
throw new JobFailure(e.getCause());
} Prevention
- Keep DB schema in sync with the SonarQube version (run upgrades fully)
- Monitor DB connectivity/timeouts for long CE tasks
- Ensure sufficient disk space for dump output
- Log the wrapped cause, not just the wrapper message
When it happens
Trigger: SQLException while scrolling the analyses select; ProjectDump.Analysis protobuf write fails; DB connection dropped mid-scroll; corrupt analysis data that fails conversion.
Common situations: Database connectivity issues during long CE project export; schema drift after SonarQube upgrade (missing columns expected by the QUERY); broken dump output stream (disk full, connection to destination closed).
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- Branch export failed after processing %d branch(es) successf
- Component Export failed after processing %d components succe
- Lines hashes export failed after processing %d files success
- Issues changelog export failed after processing %d issue cha
- Issue export failed after processing %d issues successfully
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/be5137bfaae566f7.
Report an issue: GitHub.