{"record":{"id":"8a4545fd145e597f","repo":"SonarSource/sonarqube","slug":"lines-hashes-export-failed-after-processing-d-fil","errorCode":null,"errorMessage":"Lines hashes export failed after processing %d files successfully","messagePattern":"Lines hashes export failed after processing (.+?) files successfully","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/file/ExportLineHashesStep.java","lineNumber":86,"sourceCode":"      if (allFileUuids.isEmpty()) {\n        return;\n      }\n      try (DbSession dbSession = dbClient.openSession(false)) {\n        ProjectDump.LineHashes.Builder builder = ProjectDump.LineHashes.newBuilder();\n        for (List<String> fileUuids : partition(allFileUuids, PARTITION_SIZE_FOR_ORACLE)) {\n          stmt = createStatement(dbSession, fileUuids);\n          rs = stmt.executeQuery();\n          while (rs.next()) {\n            ProjectDump.LineHashes lineHashes = toLinehashes(builder, rs);\n            output.write(lineHashes);\n            count++;\n          }\n          closeQuietly(rs);\n          closeQuietly(stmt);\n        }\n        LoggerFactory.getLogger(getClass()).debug(\"Lines hashes of {} files exported\", count);\n      } catch (Exception e) {\n        throw new IllegalStateException(format(\"Lines hashes export failed after processing %d files successfully\", count), e);\n      } finally {\n        closeQuietly(rs);\n        closeQuietly(stmt);\n      }\n    }\n  }\n\n  private PreparedStatement createStatement(DbSession dbSession, List<String> uuids) throws SQLException {\n    String sql = \"select\" +\n      \" file_uuid, line_hashes, project_uuid\" +\n      \" FROM file_sources\" +\n      \" WHERE file_uuid in (%s)\" +\n      \" order by created_at, uuid\";\n    PreparedStatement stmt = dbClient.getMyBatis().newScrollingSelectStatement(dbSession, format(sql, wildCardStringFor(uuids)));\n    try {\n      int i = 1;\n      for (String uuid : uuids) {\n        stmt.setString(i, uuid);","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/file/ExportLineHashesStep.java#L68-L104","documentation":"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.","triggerScenarios":"SQLException on the per-batch line-hashes select (e.g. too many placeholders, connection drop); protobuf write failure; corrupt FILE_LINES_HASHES data.","commonSituations":"Long exports hitting DB timeouts or dropped connections; memory/CPU issues with very large projects; corrupt line-hash blobs after partial upgrade.","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."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// pre-check that line-hash blobs are readable for a sample of files\nSELECT uuid FROM file_lines_hashes LIMIT 100; // then parse blob columns client-side","typeGuard":null,"tryCatchPattern":"try {\n  exportLineHashesStep.execute(context);\n} catch (IllegalStateException e) {\n  logger.error(\"Line hashes export failed after {} files: {}\", parseCount(e.getMessage()), e.getCause(), e);\n  throw new JobFailure(e.getCause());\n}","preventionTips":["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"],"tags":["export","line-hashes","database","sonarqube"],"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-14T05:17:10.506Z"}