SonarSource/sonarqube · critical · IllegalStateException
Lines hashes export failed after processing %d files success
Error message
Lines hashes export failed after processing %d files successfully
What it means
ExportLineHashesStep exports line hashes per file, batching file uuids into SQL IN clauses via wildCardStringFor. Any exception while scrolling/writing per-file data is wrapped in an IllegalStateException reporting how many files were exported successfully before the failure; statement and result set are closed in finally.
Source
Thrown at server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/file/ExportLineHashesStep.java:86
if (allFileUuids.isEmpty()) {
return;
}
try (DbSession dbSession = dbClient.openSession(false)) {
ProjectDump.LineHashes.Builder builder = ProjectDump.LineHashes.newBuilder();
for (List<String> fileUuids : partition(allFileUuids, PARTITION_SIZE_FOR_ORACLE)) {
stmt = createStatement(dbSession, fileUuids);
rs = stmt.executeQuery();
while (rs.next()) {
ProjectDump.LineHashes lineHashes = toLinehashes(builder, rs);
output.write(lineHashes);
count++;
}
closeQuietly(rs);
closeQuietly(stmt);
}
LoggerFactory.getLogger(getClass()).debug("Lines hashes of {} files exported", count);
} catch (Exception e) {
throw new IllegalStateException(format("Lines hashes export failed after processing %d files successfully", count), e);
} finally {
closeQuietly(rs);
closeQuietly(stmt);
}
}
}
private PreparedStatement createStatement(DbSession dbSession, List<String> uuids) throws SQLException {
String sql = "select" +
" file_uuid, line_hashes, project_uuid" +
" FROM file_sources" +
" WHERE file_uuid in (%s)" +
" order by created_at, uuid";
PreparedStatement stmt = dbClient.getMyBatis().newScrollingSelectStatement(dbSession, format(sql, wildCardStringFor(uuids)));
try {
int i = 1;
for (String uuid : uuids) {
stmt.setString(i, uuid);View on GitHub (pinned to 184c821202)
Solutions
- Inspect the wrapped cause for the underlying SQL/IO error and fix it (timeouts, connection pool, network).
- Reduce batch pressure by exporting smaller projects or increasing DB timeouts/connection limits.
- Verify FILE_LINES_HASHES rows are parseable for the failing file; delete/repair corrupt rows.
- Retry the CE export task once the DB issue is resolved.
Defensive patterns
Strategy: retry
Validate before calling
// pre-check that line-hash blobs are readable for a sample of files SELECT uuid FROM file_lines_hashes LIMIT 100; // then parse blob columns client-side
Try / catch
try {
exportLineHashesStep.execute(context);
} catch (IllegalStateException e) {
logger.error("Line hashes export failed after {} files: {}", parseCount(e.getMessage()), e.getCause(), e);
throw new JobFailure(e.getCause());
} Prevention
- Increase DB timeouts and connection pool size for very large projects
- Verify FILE_LINES_HASHES blobs parse after upgrades
- Watch for network drops during long scrolling queries
- Rely on finally-close of rs/stmt to avoid leaked resources compounding failures
When it happens
Trigger: SQLException on the per-batch line-hashes select (e.g. too many placeholders, connection drop); protobuf write failure; corrupt FILE_LINES_HASHES data.
Common situations: Long exports hitting DB timeouts or dropped connections; memory/CPU issues with very large projects; corrupt line-hash blobs after partial upgrade.
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
- Analysis Export failed after processing %d analyses successf
- Branch export failed after processing %d branch(es) successf
- Component Export failed after processing %d components succe
- 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/8a4545fd145e597f.
Report an issue: GitHub.