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

  1. Inspect the wrapped cause for the underlying SQL/IO error and fix it (timeouts, connection pool, network).
  2. Reduce batch pressure by exporting smaller projects or increasing DB timeouts/connection limits.
  3. Verify FILE_LINES_HASHES rows are parseable for the failing file; delete/repair corrupt rows.
  4. 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

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


AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09). Data as JSON: /api/errors/8a4545fd145e597f. Report an issue: GitHub.