{"record":{"id":"6c0b0641a6cd6423","repo":"pinpoint-apm/pinpoint","slug":"cannot-create-an-existing-table","errorCode":null,"errorMessage":"Cannot create an existing table : ","messagePattern":"Cannot create an existing table : ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hbase/hbase-schema/src/main/java/com/navercorp/pinpoint/hbase/schema/core/command/HbaseSchemaCommandManager.java","lineNumber":113,"sourceCode":"\n        List<TableChange> tableChanges = changeSet.getTableChanges();\n        try {\n            for (TableChange tableChange : tableChanges) {\n                applyTableChange(tableChange);\n            }\n        } catch (Exception e) {\n            throw new InvalidHbaseSchemaException(\"Error applying changeSet : \" + changeSet.getId(), e);\n        }\n    }\n\n    private void applyTableChange(TableChange tableChange) {\n        ChangeType changeType = tableChange.getType();\n        TableName tableName = TableName.valueOf(namespace, tableChange.getName());\n\n        switch (changeType) {\n            case CREATE -> {\n                if (tableCommandMap.containsKey(tableName)) {\n                    throw new IllegalArgumentException(\"Cannot create an existing table : \" + tableName);\n                }\n                TableCommand createTableCommand = new CreateTableCommand(tableName, compressionAlgorithm, tableChange.getSplitKeys());\n                createTableCommand.applyConfiguration(tableChange.getTableConfiguration());\n                createTableCommand.applyColumnFamilyChanges(tableChange.getColumnFamilyChanges());\n                tableCommandMap.put(tableName, createTableCommand);\n            }\n            case MODIFY -> {\n                TableCommand tableCommand = tableCommandMap.get(tableName);\n                if (tableCommand == null) {\n                    throw new IllegalArgumentException(\"Cannot modify a non-existent table : \" + tableName);\n                }\n                tableCommand.applyConfiguration(tableChange.getTableConfiguration());\n                tableCommand.applyColumnFamilyChanges(tableChange.getColumnFamilyChanges());\n            }\n            default ->\n                throw new UnsupportedOperationException(\"Invalid change type : \" + changeType);\n        }\n        affectedTables.add(tableName);","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/hbase/hbase-schema/src/main/java/com/navercorp/pinpoint/hbase/schema/core/command/HbaseSchemaCommandManager.java#L95-L131","documentation":"In applyTableChange, a TableChange of type CREATE is rejected with IllegalArgumentException if a command for the same table name was already registered in tableCommandMap during this change set — i.e. the change set tries to create a table that a prior TableChange (or the existing-table check) already created.","triggerScenarios":"Calling applyChangeSet with a change set containing two CREATE TableChanges for the same table name, or a CREATE following an earlier CREATE of the same table within the run.","commonSituations":"Copy-pasted change set entries, merging change sets from branches that both introduce the same table, or re-adding a table definition without removing the older duplicate.","solutions":["Remove the duplicate CREATE TableChange for that table name from the change set.","If the table already exists in HBase, ensure schema initialization filters it out (existing tables are typically detected before applying).","Merge the two column-family definitions into a single CREATE entry."],"exampleFix":"// before\nchanges.add(new TableChange(CREATE, \"AgentInfo\", cfA));\nchanges.add(new TableChange(CREATE, \"AgentInfo\", cfB)); // duplicate\n// after\nchanges.add(new TableChange(CREATE, \"AgentInfo\", cfA, cfB)); // single entry with all column families","handlingStrategy":"validation","validationCode":"Set<String> seen = new HashSet<>();\nfor (TableChange tc : changeSet.getTableChanges()) {\n    if (tc.getType() == ChangeType.CREATE && !seen.add(tc.getName())) {\n        throw new IllegalArgumentException(\"Duplicate CREATE for table \" + tc.getName());\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    manager.applyChangeSet(changeSet);\n} catch (InvalidHbaseSchemaException e) {\n    if (e.getCause() instanceof IllegalArgumentException iae) {\n        logger.error(\"Duplicate table create: {}\", iae.getMessage());\n    }\n}","preventionTips":["Deduplicate CREATE entries per table name in each change set.","Merge multiple column families into one CREATE TableChange.","Review branch merges that both add the same new table."],"tags":["hbase","schema-migration","duplicate-table"],"backgroundTag":"file-already-exists","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}