{"record":{"id":"3e7487bb767fe33e","repo":"prestodb/presto","slug":"already-exists-3e7487","errorCode":"ALREADY_EXISTS","errorMessage":"Partition already exists for table '%s.%s': %s","messagePattern":"Partition already exists for table '(.+?)\\.(.+?)': (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/SemiTransactionalHiveMetastore.java","lineNumber":894,"sourceCode":"            partitionActionsOfTable.put(\n                    partition.getValues(),\n                    new Action<>(ActionType.ADD, new PartitionAndMore(partition, currentLocation, Optional.empty(), statistics, statistics), context));\n            return;\n        }\n        switch (oldPartitionAction.getType()) {\n            case DROP: {\n                if (!oldPartitionAction.getContext().getIdentity().getUser().equals(session.getUser())) {\n                    throw new PrestoException(TRANSACTION_CONFLICT, \"Operation on the same partition with different user in the same transaction is not supported\");\n                }\n                partitionActionsOfTable.put(\n                        partition.getValues(),\n                        new Action<>(ActionType.ALTER, new PartitionAndMore(partition, currentLocation, Optional.empty(), statistics, statistics), context));\n                break;\n            }\n            case ADD:\n            case ALTER:\n            case INSERT_EXISTING:\n                throw new PrestoException(ALREADY_EXISTS, format(\"Partition already exists for table '%s.%s': %s\", databaseName, tableName, partition.getValues()));\n            default:\n                throw new IllegalStateException(\"Unknown action type\");\n        }\n    }\n\n    public synchronized void dropPartition(\n            ConnectorSession session,\n            String databaseName,\n            String tableName,\n            String tablePath,\n            List<String> partitionValues)\n    {\n        setShared();\n        Map<List<String>, Action<PartitionAndMore>> partitionActionsOfTable = partitionActions.computeIfAbsent(new SchemaTableName(databaseName, tableName), k -> new HashMap<>());\n        Action<PartitionAndMore> oldPartitionAction = partitionActionsOfTable.get(partitionValues);\n        if (oldPartitionAction == null) {\n            HdfsContext context = new HdfsContext(session, databaseName, tableName, tablePath, false);\n            partitionActionsOfTable.put(partitionValues, new Action<>(ActionType.DROP, null, context));","sourceCodeStart":876,"sourceCodeEnd":912,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/SemiTransactionalHiveMetastore.java#L876-L912","documentation":"While adding a partition inside a semi-transactional session, an existing pending action for the same partition conflicts: e.g. a DROP followed by an ADD issued by a different user, or otherwise incompatible sequential actions, so a TRANSACTION_CONFLICT PrestoException is thrown to prevent two users mutating the same partition in one transaction.","triggerScenarios":"Thrown at presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/SemiTransactionalHiveMetastore.java:894 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure a single transaction does not interleave partition drop/add across different users","Split conflicting operations into separate transactions","Coordinate concurrent jobs so they do not target the same partition simultaneously"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}