{"record":{"id":"32230707de65edb1","repo":"apache/seatunnel","slug":"partition-already-exists","errorCode":null,"errorMessage":"Partition {} already exists","messagePattern":"Partition (.+?) already exists","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveMetaStoreCatalog.java","lineNumber":507,"sourceCode":"                    HiveConnectorErrorCode.CREATE_HIVE_TABLE_FAILED, errorMsg, e);\n        } catch (Exception e) {\n            throw new TException(\n                    \"Unexpected error creating table: \"\n                            + tbl.getDbName()\n                            + \".\"\n                            + tbl.getTableName(),\n                    e);\n        }\n    }\n\n    public void addPartitions(\n            @NonNull String dbName, @NonNull String tableName, List<String> partitions)\n            throws TException {\n        for (String partition : partitions) {\n            try {\n                getClient().appendPartition(dbName, tableName, partition);\n            } catch (AlreadyExistsException ae) {\n                log.warn(\"Partition {} already exists\", partition);\n            }\n        }\n    }\n\n    public void dropPartitions(\n            @NonNull String dbName, @NonNull String tableName, List<String> partitions)\n            throws TException {\n        for (String partition : partitions) {\n            getClient().dropPartition(dbName, tableName, partition, false);\n        }\n    }\n\n    public boolean tableExists(@NonNull String dbName, @NonNull String tableName) {\n        try {\n            return getClient().tableExists(dbName, tableName);\n        } catch (TException e) {\n            String msg = String.format(\"Failed to check if table %s.%s exists\", dbName, tableName);\n            throw new HiveConnectorException(","sourceCodeStart":489,"sourceCodeEnd":525,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveMetaStoreCatalog.java#L489-L525","documentation":"This is a warning logged by HiveMetaStoreCatalog.addPartitions when the Hive Metastore reports that a partition being added already exists (AlreadyExistsException from HMS appendPartition). The catalog treats this as a benign, idempotent outcome: the partition is already registered, so the loop continues with the next partition instead of failing the operation. It is not thrown to the caller; it only signals redundant partition registration.","triggerScenarios":"Calling addPartitions(dbName, tableName, partitions) with partition strings (e.g. 'year=2024/month=01') that were already appended to the Hive table via a previous addPartitions call, an ALTER TABLE ADD PARTITION, or data written by another job that already registered the partition.","commonSituations":"Re-running a failed or completed batch job that re-registers the same partitions; two concurrent jobs writing to the same Hive table and both adding the same partition; a checkpoint restart replaying partition registration; manually creating partitions in Hive and then running a SeaTunnel job that also adds them.","solutions":["Treat this as informational: the partition exists and the operation is effectively idempotent; no code change is required.","If the warning is noisy, filter partitions before calling addPartitions by checking existing partitions via the catalog and only adding missing ones.","Deduplicate the partition list passed to addPartitions so each partition is appended only once per call.","If the partition exists but has wrong location/stats, drop it first with dropPartitions and re-add it rather than relying on appendPartition."],"exampleFix":"// before\ncatalog.addPartitions(dbName, tableName, partitions);\n\n// after\nList<String> existing = catalog.listPartitionNames(dbName, tableName);\nList<String> missing = partitions.stream()\n        .filter(p -> !existing.contains(p))\n        .collect(Collectors.toList());\ncatalog.addPartitions(dbName, tableName, missing);","handlingStrategy":"validation","validationCode":"Set<String> existing = new HashSet<>(catalog.listPartitionNames(dbName, tableName));\nList<String> toAdd = partitions.stream().filter(p -> !existing.contains(p)).collect(Collectors.toList());\ncatalog.addPartitions(dbName, tableName, toAdd);","typeGuard":null,"tryCatchPattern":"// Safe to ignore: the catalog itself catches AlreadyExistsException and logs a warn.\n// No caller-side catch needed; treat the warning as an idempotent no-op.","preventionTips":["Deduplicate partition lists before registering them.","Check existing partition names before addPartitions on restart/replay paths.","Design jobs so partition registration is idempotent and re-runnable."],"tags":["hive","metastore","partition","idempotent","duplicate"],"backgroundTag":"file-already-exists","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}