pinpoint-apm/pinpoint · error · IllegalArgumentException

Cannot create an existing table :

Error message

Cannot create an existing table : 

What it means

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.

Source

Thrown at hbase/hbase-schema/src/main/java/com/navercorp/pinpoint/hbase/schema/core/command/HbaseSchemaCommandManager.java:113

        List<TableChange> tableChanges = changeSet.getTableChanges();
        try {
            for (TableChange tableChange : tableChanges) {
                applyTableChange(tableChange);
            }
        } catch (Exception e) {
            throw new InvalidHbaseSchemaException("Error applying changeSet : " + changeSet.getId(), e);
        }
    }

    private void applyTableChange(TableChange tableChange) {
        ChangeType changeType = tableChange.getType();
        TableName tableName = TableName.valueOf(namespace, tableChange.getName());

        switch (changeType) {
            case CREATE -> {
                if (tableCommandMap.containsKey(tableName)) {
                    throw new IllegalArgumentException("Cannot create an existing table : " + tableName);
                }
                TableCommand createTableCommand = new CreateTableCommand(tableName, compressionAlgorithm, tableChange.getSplitKeys());
                createTableCommand.applyConfiguration(tableChange.getTableConfiguration());
                createTableCommand.applyColumnFamilyChanges(tableChange.getColumnFamilyChanges());
                tableCommandMap.put(tableName, createTableCommand);
            }
            case MODIFY -> {
                TableCommand tableCommand = tableCommandMap.get(tableName);
                if (tableCommand == null) {
                    throw new IllegalArgumentException("Cannot modify a non-existent table : " + tableName);
                }
                tableCommand.applyConfiguration(tableChange.getTableConfiguration());
                tableCommand.applyColumnFamilyChanges(tableChange.getColumnFamilyChanges());
            }
            default ->
                throw new UnsupportedOperationException("Invalid change type : " + changeType);
        }
        affectedTables.add(tableName);

View on GitHub (pinned to 744c3d3075)

Solutions

  1. Remove the duplicate CREATE TableChange for that table name from the change set.
  2. If the table already exists in HBase, ensure schema initialization filters it out (existing tables are typically detected before applying).
  3. Merge the two column-family definitions into a single CREATE entry.

Example fix

// before
changes.add(new TableChange(CREATE, "AgentInfo", cfA));
changes.add(new TableChange(CREATE, "AgentInfo", cfB)); // duplicate
// after
changes.add(new TableChange(CREATE, "AgentInfo", cfA, cfB)); // single entry with all column families
Defensive patterns

Strategy: validation

Validate before calling

Set<String> seen = new HashSet<>();
for (TableChange tc : changeSet.getTableChanges()) {
    if (tc.getType() == ChangeType.CREATE && !seen.add(tc.getName())) {
        throw new IllegalArgumentException("Duplicate CREATE for table " + tc.getName());
    }
}

Try / catch

try {
    manager.applyChangeSet(changeSet);
} catch (InvalidHbaseSchemaException e) {
    if (e.getCause() instanceof IllegalArgumentException iae) {
        logger.error("Duplicate table create: {}", iae.getMessage());
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


AI-assisted analysis of pinpoint-apm/pinpoint@744c3d3075 (2026-09-07). Data as JSON: /api/errors/6c0b0641a6cd6423. Report an issue: GitHub.