SonarSource/sonarqube · error · IllegalStateException

Event Export failed after processing

Error message

Event Export failed after processing %d events successfully

What it means

ExportEventsStep scrolls project events from the database and streams them into the dump. Any exception during the scroll/write loop is wrapped in an IllegalStateException reporting how many events were exported successfully before the failure. The resulting dump is incomplete and the export task fails.

Solutions

  1. Inspect the cause chain to distinguish DB errors from IO write errors
  2. Check database health/connection pool settings for long-running scroll queries
  3. Look for EVENTS rows for the project with null/invalid columns that break conversion
  4. Ensure disk space on the dump volume, then rerun the export
Defensive patterns

Strategy: try-catch

Validate before calling

try (PreparedStatement probe = db.newScrollingSelectStatement(dbSession, QUERY)) { probe.executeQuery().close(); } // fail fast on DB issues before export

Try / catch

try { exportEventsStep.execute(); } catch (IllegalStateException e) { logger.error("Event export failed after N events: {}", e.getCause(), e); markDumpInvalid(); }

Prevention

When it happens

Trigger: SQLException from the scrolling select of EVENTS rows, a ResultSet conversion failure in the event mapping, or an IOException writing the protobuf event to the StreamWriter, after `count` events were written.

Common situations: DB connection drop/timeout during a long scroll; corrupt EVENTS rows (e.g. null fields) failing conversion; dump filesystem full mid-export.

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/bab0579f32203ca8. Report an issue: GitHub.

Appendix: source

Thrown at server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/steps/ExportEventsStep.java:78

  @Override
  public void execute(Context context) {
    long count = 0L;
    try (
      StreamWriter<ProjectDump.Event> output = dumpWriter.newStreamWriter(DumpElement.EVENTS);
      DbSession dbSession = dbClient.openSession(false);
      PreparedStatement stmt = buildSelectStatement(dbSession);
      ResultSet rs = stmt.executeQuery()) {

      ProjectDump.Event.Builder builder = ProjectDump.Event.newBuilder();
      while (rs.next()) {
        ProjectDump.Event event = convertToEvent(rs, builder);
        output.write(event);
        count++;
      }
      LoggerFactory.getLogger(getClass()).debug("{} events exported", count);

    } catch (Exception e) {
      throw new IllegalStateException(format("Event Export failed after processing %d events successfully", count), e);
    }
  }

  private PreparedStatement buildSelectStatement(DbSession dbSession) throws SQLException {
    PreparedStatement stmt = dbClient.getMyBatis().newScrollingSelectStatement(dbSession, QUERY);
    try {
      stmt.setString(1, projectHolder.projectDto().getUuid());
      stmt.setBoolean(2, true);
      stmt.setString(3, SnapshotDto.STATUS_PROCESSED);
      stmt.setBoolean(4, true);
      return stmt;
    } catch (Exception e) {
      DatabaseUtils.closeQuietly(stmt);
      throw e;
    }
  }

  private ProjectDump.Event convertToEvent(ResultSet rs, ProjectDump.Event.Builder builder) throws SQLException {

View on GitHub (pinned to 184c821202)