{"record":{"id":"8960c0cdeb71051e","repo":"apache/beam","slug":"interrupted-while-inserting","errorCode":null,"errorMessage":"Interrupted while inserting ","messagePattern":"Interrupted while inserting ","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryServicesImpl.java","lineNumber":1318,"sourceCode":"                // TODO (https://github.com/apache/beam/issues/20891): Select the retry rows(using\n                // errorIndex) from the batch of rows which attempted insertion in this call.\n                // Not the entire set of rows in rowsToPublish.\n                if (retryIds != null) {\n                  // retryIds is non-null exactly when idsToPublish is non-null; see where both are\n                  // initialized above.\n                  retryIds.add(checkStateNotNull(idsToPublish).get(errorIndex));\n                }\n              } else {\n                numFailedRows += 1;\n                errorContainer.add(failedInserts, error, ref, rowsToPublish.get(errorIndex));\n              }\n            }\n          }\n          // Accumulate the longest throttled time across all parallel threads\n          throttlingMsecs.inc(maxThrottlingMsec.get());\n        } catch (InterruptedException e) {\n          Thread.currentThread().interrupt();\n          throw new IOException(\"Interrupted while inserting \" + rowsToPublish);\n        } catch (ExecutionException e) {\n          streamingInsertsResults.updateStreamingInsertsMetrics(\n              ref, rowList.size(), rowList.size());\n          throw new RuntimeException(e.getCause());\n        }\n\n        if (allErrors.isEmpty()) {\n          break;\n        }\n        long nextBackoffMillis = backoff.nextBackOffMillis();\n        if (nextBackoffMillis == BackOff.STOP) {\n          break;\n        }\n        try {\n          sleeper.sleep(nextBackoffMillis);\n        } catch (InterruptedException e) {\n          Thread.currentThread().interrupt();\n          throw new IOException(\"Interrupted while waiting before retrying insert of \" + retryRows);","sourceCodeStart":1300,"sourceCodeEnd":1336,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryServicesImpl.java#L1300-L1336","documentation":"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.","triggerScenarios":"Worker shutdown or pipeline cancellation while multiple parallel insertAll requests are in flight and the coordinating thread is interrupted (in sleeper or executor wait).","commonSituations":"Job cancellation in Dataflow; container/preemptible VM shutdown mid-write; executor service shut down by user code.","solutions":["Allow the pipeline stage to drain before cancelling/shutting down workers","Avoid shutting down executor threads that Beam sinks are using","Check worker logs for preemption/eviction if the error appears without a cancel","Retry the pipeline — the interrupted batch was not acknowledged and can be re-run idempotently with deterministic row IDs"],"exampleFix":"// before\nexecutor.shutdownNow(); // during an active write stage\n// after\npipeline.waitUntilFinish();\nexecutor.shutdown();","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  pipeline.run().waitUntilFinish();\n} catch (IOException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Interrupted while inserting\")) {\n    // batch not acknowledged; safe to re-run with deterministic row IDs\n  }\n}","preventionTips":["Avoid shutting down executors during active write stages","Let jobs drain before cancelling; avoid SIGKILL on workers","Use deterministic row IDs so retried batches are idempotent","Monitor preemption on preemptible workers"],"tags":["bigquery","gcp","threading","interruption"],"backgroundTag":"thread-interrupted","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}