{"record":{"id":"74d07550316cfc17","repo":"SonarSource/sonarqube","slug":"new-code-periods-export-failed-after-processing-d","errorCode":null,"errorMessage":"New Code Periods Export failed after processing %d new code periods successfully","messagePattern":"New Code Periods Export failed after processing (.+?) new code periods successfully","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/steps/ExportNewCodePeriodsStep.java","lineNumber":73,"sourceCode":"        builder.clear()\n          .setUuid(newCodePeriod.getUuid())\n          .setProjectUuid(newCodePeriod.getProjectUuid())\n          .setType(newCodePeriod.getType().name());\n\n        if (newCodePeriod.getBranchUuid() != null) {\n          builder.setBranchUuid(newCodePeriod.getBranchUuid());\n        }\n\n        if (newCodePeriod.getValue() != null) {\n          builder.setValue(newCodePeriod.getValue());\n        }\n        output.write(builder.build());\n        ++count;\n      }\n\n      LoggerFactory.getLogger(getClass()).debug(\"{} new code periods exported\", count);\n    } catch (Exception e) {\n      throw new IllegalStateException(format(\"New Code Periods Export failed after processing %d new code periods successfully\", count), e);\n    }\n  }\n\n  @Override\n  public String getDescription() {\n    return \"Export new code periods\";\n  }\n}\n","sourceCodeStart":55,"sourceCodeEnd":82,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/steps/ExportNewCodePeriodsStep.java#L55-L82","documentation":"ExportNewCodePeriodsStep.execute() exports all NewCodePeriod entries for the project to the dump, counting successes. If any exception occurs during DB iteration or output writing, it is wrapped in an IllegalStateException reporting the number of successfully exported new code periods. The library throws this to fail the CE export task deterministically on partial export.","triggerScenarios":"Any exception while querying NEW_CODE_PERIOD rows or writing each protobuf builder to output.write() inside execute() — e.g. SQLException on the scrolling select, conversion error for a branch reference, or dump I/O failure.","commonSituations":"Database timeout during export of a project with many branches; a NewCodePeriod row referencing a deleted branch failing conversion; disk full while writing the dump.","solutions":["Inspect the cause exception to identify the failing row or I/O problem","Verify DB connectivity and retry the export after transient failures","Clean up orphaned NEW_CODE_PERIOD rows referencing deleted branches","Ensure sufficient disk space and permissions on the CE worker dump directory"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// check for orphaned new code period rows referencing missing branches beforehand\nSELECT ncp.* FROM new_code_periods ncp\nLEFT JOIN project_branches pb ON pb.uuid = ncp.branch_uuid\nWHERE pb.uuid IS NULL;","typeGuard":null,"tryCatchPattern":"try {\n  step.execute(context);\n} catch (IllegalStateException e) {\n  LOGGER.error(\"New code periods export failed after {} items; cause: {}\", e.getCause(), e);\n}","preventionTips":["Clean up NEW_CODE_PERIOD rows when branches are deleted","Verify DB timeouts accommodate projects with many branches","Monitor dump directory disk usage"],"tags":["database","export","compute-engine","new-code-period"],"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-14T11:17:12.474Z"}