SonarSource/sonarqube · error · IllegalStateException

Could not save report ${uuid} part ${partNumber} file to dat

Error message

Could not save report ${uuid} part ${partNumber} file to database

What it means

ReportSubmitter.saveFileOnDb inserts one report part into CE_TASK_INPUT by streaming the part file into the database. An IOException while opening/reading the part file is wrapped in this IllegalStateException identifying task uuid and part number. Note it only wraps IO errors — DB errors propagate as-is.

Source

Thrown at server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/queue/ReportSubmitter.java:348

      toChannel.transferFrom(sourceChannel, 0, byteSize);
    }
  }

  private static void deleteTempFile(File file) {
    try {
      Files.delete(file.toPath());
    } catch (IOException e) {
      LOGGER.warn("Failed to delete temp file {}", file.getAbsolutePath(), e);
    }
  }

  private void saveFileOnDb(DbSession dbSession, CeTaskSubmit.Builder submit, long partIndex, File file) {
    long partNumber = partIndex + 1;
    LOGGER.debug("Saving report {} part {} on DB from file {}", submit.getUuid(), partNumber, file.toPath());
    try (InputStream is = Files.newInputStream(file.toPath())) {
      dbClient.ceTaskInputDao().insert(dbSession, submit.getUuid(), partNumber, is);
    } catch (IOException e) {
      throw new IllegalStateException("Could not save report " + submit.getUuid() + " part " + partNumber + " file to database", e);
    }
  }

}

View on GitHub (pinned to 184c821202)

Solutions

  1. Check server logs for the cause and whether the part temp file still exists at the logged path
  2. Confirm the SonarQube process can read the temp directory and files it creates
  3. Exclude the temp directory from external cleanup services
  4. Verify database storage (tablespace/disk) is healthy if inserts fail at scale
Defensive patterns

Strategy: try-catch

Validate before calling

long usable = Files.getFileStore(tempDir).getUsableSpace(); if (usable < partSize) abortSubmit();

Try / catch

try { submit(); } catch (ServerException e) if (e.message.contains("part")) { inspectCeTaskInputTable(); }

Prevention

When it happens

Trigger: Files.newInputStream(partFile) fails because the part temp file is missing/unreadable, or reading the stream during insert throws (storage error).

Common situations: Temp files cleaned up by another process before insertion; permission problems on the temp dir; disk errors; extremely large parts timing out underlying I/O.

Related errors


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