{"record":{"id":"a9f56c20c6628026","repo":"apache/seatunnel","slug":"truncate-table-interrupted","errorCode":null,"errorMessage":"Truncate table interrupted","messagePattern":"Truncate table interrupted","errorType":"exception","errorClass":"CatalogException","httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-bigquery/src/main/java/org/apache/seatunnel/connectors/bigquery/catalog/BigQueryCatalog.java","lineNumber":374,"sourceCode":"    public void truncateTable(TablePath tablePath, boolean ignoreIfNotExists)\n            throws TableNotExistException, CatalogException {\n        if (!tableExists(tablePath)) {\n            if (ignoreIfNotExists) {\n                return;\n            }\n            throw new TableNotExistException(catalogName, tablePath);\n        }\n        String query =\n                String.format(\n                        \"TRUNCATE TABLE `%s.%s` ;\",\n                        getDatasetName(tablePath), tablePath.getTableName());\n        QueryJobConfiguration queryConfig = QueryJobConfiguration.newBuilder(query).build();\n        try {\n            bigquery.query(queryConfig);\n            log.info(\"BigQuery Table '{}' truncated successfully.\", tablePath.getFullName());\n        } catch (InterruptedException e) {\n            Thread.currentThread().interrupt();\n            throw new CatalogException(\"Truncate table interrupted\", e);\n        } catch (Exception e) {\n            throw new CatalogException(\n                    \"Failed to truncate BigQuery table: \" + tablePath.getFullName(), e);\n        }\n    }\n\n    @Override\n    public boolean isExistsData(TablePath tablePath) {\n        if (!tableExists(tablePath)) {\n            return false;\n        }\n        String query =\n                String.format(\n                        \"SELECT 1 FROM `%s.%s` LIMIT 1 ;\",\n                        getDatasetName(tablePath), tablePath.getTableName());\n        QueryJobConfiguration queryConfig = QueryJobConfiguration.newBuilder(query).build();\n        try {\n            return bigquery.query(queryConfig).iterateAll().iterator().hasNext();","sourceCodeStart":356,"sourceCodeEnd":392,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-bigquery/src/main/java/org/apache/seatunnel/connectors/bigquery/catalog/BigQueryCatalog.java#L356-L392","documentation":"Thrown by BigQueryCatalog.truncateTable when bigquery.query(queryConfig) throws InterruptedException while running the TRUNCATE TABLE statement. The thread's interrupt flag is restored before wrapping the interruption in a CatalogException. It signals the truncate job was cancelled because the thread was interrupted (e.g. job cancellation or shutdown), not a BigQuery data error.","triggerScenarios":"Calling truncateTable when the thread is interrupted while synchronously waiting for the BigQuery TRUNCATE TABLE query job to complete — typically during SeaTunnel job cancellation, engine shutdown, or a deadline watchdog interrupting the task thread.","commonSituations":"User cancels a running SeaTunnel job that triggers save-mode truncate; Zeta engine task termination during checkpoint/stop; executor shutdown mid-catalog operation.","solutions":["Verify whether the interruption was an intentional cancellation (job stop) — if so, no code fix is needed","Re-run the job if the truncate must complete; the truncate may or may not have been applied, so check table state in BigQuery","Avoid long blocking work in threads that can be interrupted, or handle InterruptedException at a higher level instead of retrying blindly"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    catalog.truncateTable(tablePath, false);\n} catch (CatalogException e) {\n    if (Thread.currentThread().isInterrupted()) {\n        LOG.warn(\"Truncate cancelled due to interruption\");\n        return; // job is being cancelled\n    }\n    throw e;\n}","preventionTips":["Avoid cancelling jobs mid save-mode truncate; check table state afterwards","Restore and respect the interrupt flag rather than swallowing it","Schedule truncates where thread interruption is unlikely (not in shutdown hooks)"],"tags":["bigquery","interrupt","truncate","thread-interrupted"],"backgroundTag":"request-timeout","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}