This is an automated email from the ASF dual-hosted git repository. krathbun pushed a commit to branch 2.1 in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/2.1 by this push: new 8b6a49ad9a Prevent offline of proper system tables (#5433) 8b6a49ad9a is described below commit 8b6a49ad9a911fd8fe59cf3da348eaddfc8a56e7 Author: Kevin Rathbun <krath...@apache.org> AuthorDate: Wed Apr 16 16:40:54 2025 -0400 Prevent offline of proper system tables (#5433) In 2.1: * Previously, could offline any table that was not ROOT. * This commit prevents offlining all system tables except for the replication table (this includes METADATA and ROOT). Does not prevent offlining all system tables in 2.1, as offlining the replication table is a desired feature. In main/4.x: * Previously, could offline any table that was not ROOT or METADATA. * This commit prevents offlining all system tables (this currently includes METADATA, ROOT, FATE, and SCAN_REF). The replication table is removed in 4.x, and we want to prevent offlining any of the currently existing system tables in 4.x. --- .../main/java/org/apache/accumulo/core/util/Validators.java | 11 +++++++++++ .../java/org/apache/accumulo/manager/FateServiceHandler.java | 9 +++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) 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 3c756ea083..2e3df5f3e9 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 class Validators { return Validator.OK; }); + public static final Validator<TableId> 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 c9ecd1d4d8..52320225ba 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.NEW_TABLE_NAME; 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 @@ class FateServiceHandler implements FateService.Iface { 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 @@ class FateServiceHandler implements FateService.Iface { 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;