apache/beam · error · IOException

Interrupted while inserting

Error message

Interrupted while inserting 

What it means

Thrown when the thread waiting on the parallel streaming-insert futures (via InterruptedException from the executor/sleeper during insertAll) is interrupted. The current thread's interrupt flag is restored and an IOException with the row list is thrown to abort the batch.

Source

Thrown at sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryServicesImpl.java:1318

                // TODO (https://github.com/apache/beam/issues/20891): Select the retry rows(using
                // errorIndex) from the batch of rows which attempted insertion in this call.
                // Not the entire set of rows in rowsToPublish.
                if (retryIds != null) {
                  // retryIds is non-null exactly when idsToPublish is non-null; see where both are
                  // initialized above.
                  retryIds.add(checkStateNotNull(idsToPublish).get(errorIndex));
                }
              } else {
                numFailedRows += 1;
                errorContainer.add(failedInserts, error, ref, rowsToPublish.get(errorIndex));
              }
            }
          }
          // Accumulate the longest throttled time across all parallel threads
          throttlingMsecs.inc(maxThrottlingMsec.get());
        } catch (InterruptedException e) {
          Thread.currentThread().interrupt();
          throw new IOException("Interrupted while inserting " + rowsToPublish);
        } catch (ExecutionException e) {
          streamingInsertsResults.updateStreamingInsertsMetrics(
              ref, rowList.size(), rowList.size());
          throw new RuntimeException(e.getCause());
        }

        if (allErrors.isEmpty()) {
          break;
        }
        long nextBackoffMillis = backoff.nextBackOffMillis();
        if (nextBackoffMillis == BackOff.STOP) {
          break;
        }
        try {
          sleeper.sleep(nextBackoffMillis);
        } catch (InterruptedException e) {
          Thread.currentThread().interrupt();
          throw new IOException("Interrupted while waiting before retrying insert of " + retryRows);

View on GitHub (pinned to 12126d8942)

Solutions

  1. Allow the pipeline stage to drain before cancelling/shutting down workers
  2. Avoid shutting down executor threads that Beam sinks are using
  3. Check worker logs for preemption/eviction if the error appears without a cancel
  4. Retry the pipeline — the interrupted batch was not acknowledged and can be re-run idempotently with deterministic row IDs

Example fix

// before
executor.shutdownNow(); // during an active write stage
// after
pipeline.waitUntilFinish();
executor.shutdown();
Defensive patterns

Strategy: try-catch

Try / catch

try {
  pipeline.run().waitUntilFinish();
} catch (IOException e) {
  if (e.getMessage() != null && e.getMessage().startsWith("Interrupted while inserting")) {
    // batch not acknowledged; safe to re-run with deterministic row IDs
  }
}

Prevention

When it happens

Trigger: Worker shutdown or pipeline cancellation while multiple parallel insertAll requests are in flight and the coordinating thread is interrupted (in sleeper or executor wait).

Common situations: Job cancellation in Dataflow; container/preemptible VM shutdown mid-write; executor service shut down by user code.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/8960c0cdeb71051e. Report an issue: GitHub.