diff --git a/core/src/main/java/org/apache/accumulo/core/util/Validators.java b/core/src/main/java/org/apache/accumulo/core/util/Validators.java index 3c756ea0834..2e3df5f3e93 100644 --- a/core/src/main/java/org/apache/accumulo/core/util/Validators.java +++ b/core/src/main/java/org/apache/accumulo/core/util/Validators.java @@ -227,4 +227,15 @@ public static Validator sameNamespaceAs(String oldTableName) { return Validator.OK; }); + public static final Validator NOT_METADATA_TABLE_ID = new Validator<>(id -> { + if (id == null) { + return Optional.of("Table id must not be null"); + } + if (MetadataTable.ID.equals(id)) { + return Optional.of( + "Table must not be the " + MetadataTable.NAME + "(Id: " + MetadataTable.ID + ") table"); + } + return Validator.OK; + }); + } diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/FateServiceHandler.java b/server/manager/src/main/java/org/apache/accumulo/manager/FateServiceHandler.java index c9ecd1d4d87..52320225bab 100644 --- a/server/manager/src/main/java/org/apache/accumulo/manager/FateServiceHandler.java +++ b/server/manager/src/main/java/org/apache/accumulo/manager/FateServiceHandler.java @@ -27,6 +27,7 @@ import static org.apache.accumulo.core.util.Validators.NOT_BUILTIN_NAMESPACE; import static org.apache.accumulo.core.util.Validators.NOT_BUILTIN_TABLE; import static org.apache.accumulo.core.util.Validators.NOT_METADATA_TABLE; +import static org.apache.accumulo.core.util.Validators.NOT_METADATA_TABLE_ID; import static org.apache.accumulo.core.util.Validators.NOT_ROOT_TABLE_ID; import static org.apache.accumulo.core.util.Validators.VALID_TABLE_ID; import static org.apache.accumulo.core.util.Validators.sameNamespaceAs; @@ -382,7 +383,9 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, long opid, FateOpe case TABLE_ONLINE: { TableOperation tableOp = TableOperation.ONLINE; validateArgumentCount(arguments, tableOp, 1); - final var tableId = validateTableIdArgument(arguments.get(0), tableOp, NOT_ROOT_TABLE_ID); + final var tableId = validateTableIdArgument(arguments.get(0), tableOp, + NOT_ROOT_TABLE_ID.and(NOT_METADATA_TABLE_ID)); + NamespaceId namespaceId = getNamespaceIdFromTableId(tableOp, tableId); final boolean canOnlineOfflineTable; @@ -410,7 +413,9 @@ public void executeFateOperation(TInfo tinfo, TCredentials c, long opid, FateOpe case TABLE_OFFLINE: { TableOperation tableOp = TableOperation.OFFLINE; validateArgumentCount(arguments, tableOp, 1); - final var tableId = validateTableIdArgument(arguments.get(0), tableOp, NOT_ROOT_TABLE_ID); + final var tableId = validateTableIdArgument(arguments.get(0), tableOp, + NOT_ROOT_TABLE_ID.and(NOT_METADATA_TABLE_ID)); + NamespaceId namespaceId = getNamespaceIdFromTableId(tableOp, tableId); final boolean canOnlineOfflineTable;