{"record":{"id":"f93054e22bdb4a8f","repo":"apache/seatunnel","slug":"failed-to-truncate-table-tablename-in-catalog","errorCode":null,"errorMessage":"Failed to truncate table ${tableName} in catalog ${catalogName}","messagePattern":"Failed to truncate table (.+?) in catalog (.+?)","errorType":"exception","errorClass":"CatalogException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-easysearch/src/main/java/org/apache/seatunnel/connectors/seatunnel/easysearch/catalog/EasysearchCatalog.java","lineNumber":239,"sourceCode":"\n    @Override\n    public void dropDatabase(TablePath tablePath, boolean ignoreIfNotExists)\n            throws DatabaseNotExistException, CatalogException {\n        try {\n            dropTable(tablePath, ignoreIfNotExists);\n        } catch (TableNotExistException ex) {\n            throw new DatabaseNotExistException(catalogName, tablePath.getDatabaseName());\n        }\n    }\n\n    @Override\n    public void truncateTable(TablePath tablePath, boolean ignoreIfNotExists) {\n        // Delete and recreate the index\n        try {\n            dropTable(tablePath, ignoreIfNotExists);\n            createTable(tablePath, null, false);\n        } catch (Exception e) {\n            throw new CatalogException(\n                    String.format(\n                            \"Failed to truncate table %s in catalog %s\",\n                            tablePath.getTableName(), catalogName),\n                    e);\n        }\n    }\n\n    @Override\n    public boolean isExistsData(TablePath tablePath) {\n        try {\n            // First check if the index exists\n            if (!ezsClient.checkIndexExist(tablePath.getTableName())) {\n                return false;\n            }\n\n            // Then check if it has documents\n            final List<IndexDocsCount> indexDocsCount =\n                    ezsClient.getIndexDocsCount(tablePath.getTableName());","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-easysearch/src/main/java/org/apache/seatunnel/connectors/seatunnel/easysearch/catalog/EasysearchCatalog.java#L221-L257","documentation":"truncateTable implements truncation by dropping and recreating the index; any failure in either step is wrapped as this CatalogException. Because it composes dropTable and createTable, the error may originate from either sub-operation.","triggerScenarios":"truncateTable called when dropTable fails (permissions, cluster unavailable, index read-only) or createTable fails (invalid settings/mappings from buildTableOptions, index template conflicts).","commonSituations":"Cluster read-only due to flood-stage watermark; recreate colliding with an alias or template; transient network failure between drop and create leaving the table missing.","solutions":["Check the chained cause to identify whether the drop or the create step failed.","Free disk space / raise the flood-stage watermark so the index is not read-only.","Verify the index can be recreated with the same settings (aliases, templates, mappings).","If a failure left the index dropped, recreate the table manually or via createTable before retrying."],"exampleFix":"// before: index blocked read-only by disk watermark\n// PUT _all/_settings {\"index.blocks.read_only_allow_delete\": null}\n// after\n// then retry truncateTable(tablePath, false)","handlingStrategy":"try-catch","validationCode":"// ensure cluster writable before truncate\nGET /_cluster/health?wait_for_status=yellow\nGET /_cat/indices/<index>?h=blocks // must not include read_only","typeGuard":null,"tryCatchPattern":"try {\n    catalog.truncateTable(tablePath, false);\n} catch (CatalogException e) {\n    // determine if index was dropped; recreate via createTable if needed\n    throw e;\n}","preventionTips":["Clear flood-stage read_only blocks before truncating","Ensure index templates/aliases allow recreation","Retry truncate only after verifying the index state"],"tags":["easysearch","catalog","truncate"],"backgroundTag":"http-error-response","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"}