This is an automated email from the ASF dual-hosted git repository.
krathbun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/main by this push:
new 2cd2a90a73 Adds a metadata constraint that prevents setting tablet
availability on system tables (#5514)
2cd2a90a73 is described below
commit 2cd2a90a739d26c3f8dbf1bcc787aec8a1ac143d
Author: Kevin Rathbun <[email protected]>
AuthorDate: Tue Apr 29 09:54:29 2025 -0400
Adds a metadata constraint that prevents setting tablet availability on
system tables (#5514)
* Adds a metadata constraint:
Adds a metadata constraint that prevents setting tablet availability on
system tables.
---
.../server/constraints/MetadataConstraints.java | 8 +++++++
.../constraints/MetadataConstraintsTest.java | 28 ++++++++++++++++++++++
2 files changed, 36 insertions(+)
diff --git
a/server/base/src/main/java/org/apache/accumulo/server/constraints/MetadataConstraints.java
b/server/base/src/main/java/org/apache/accumulo/server/constraints/MetadataConstraints.java
index c766916852..2c18a5c514 100644
---
a/server/base/src/main/java/org/apache/accumulo/server/constraints/MetadataConstraints.java
+++
b/server/base/src/main/java/org/apache/accumulo/server/constraints/MetadataConstraints.java
@@ -301,6 +301,8 @@ public class MetadataConstraints implements Constraint {
return "Malformed availability value";
case 4006:
return "Malformed mergeability value";
+ case 4007:
+ return "Tried to set availability of a system table";
}
return null;
@@ -376,6 +378,12 @@ public class MetadataConstraints implements Constraint {
case (TabletColumnFamily.AVAILABILITY_QUAL):
try {
TabletAvailabilityUtil.fromValue(new Value(columnUpdate.getValue()));
+ if (!violations.contains((short) 4)) {
+ KeyExtent ke = KeyExtent.fromMetaRow(new Text(mutation.getRow()));
+ if (ke.isSystemTable()) {
+ addViolation(violations, 4007);
+ }
+ }
} catch (IllegalArgumentException e) {
addViolation(violations, 4005);
}
diff --git
a/server/base/src/test/java/org/apache/accumulo/server/constraints/MetadataConstraintsTest.java
b/server/base/src/test/java/org/apache/accumulo/server/constraints/MetadataConstraintsTest.java
index 87a5595747..1f27dbc979 100644
---
a/server/base/src/test/java/org/apache/accumulo/server/constraints/MetadataConstraintsTest.java
+++
b/server/base/src/test/java/org/apache/accumulo/server/constraints/MetadataConstraintsTest.java
@@ -33,6 +33,7 @@ import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
+import org.apache.accumulo.core.client.admin.TabletAvailability;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Range;
@@ -689,6 +690,33 @@ public class MetadataConstraintsTest {
assertTrue(violations.isEmpty());
}
+ @Test
+ public void testAvailabilityColumn() {
+ MetadataConstraints mc = new MetadataConstraints();
+ Mutation m;
+ List<Short> violations;
+
+ for (var sysTable : SystemTables.values()) {
+ KeyExtent ke = new KeyExtent(sysTable.tableId(), null, null);
+ m = new Mutation(ke.toMetaRow());
+ TabletColumnFamily.AVAILABILITY_COLUMN.put(m, new
Value(TabletAvailability.UNHOSTED.name()));
+ assertViolation(mc, m, (short) 4007);
+ }
+
+ m = new Mutation(new Text("0;foo"));
+ TabletColumnFamily.AVAILABILITY_COLUMN.put(m, new Value("INVALID"));
+ assertViolation(mc, m, (short) 4005);
+
+ m = new Mutation(new Text("foo"));
+ TabletColumnFamily.AVAILABILITY_COLUMN.put(m, new
Value(TabletAvailability.UNHOSTED.name()));
+ assertViolation(mc, m, (short) 4);
+
+ m = new Mutation(new Text("0;foo"));
+ TabletColumnFamily.AVAILABILITY_COLUMN.put(m, new
Value(TabletAvailability.UNHOSTED.name()));
+ violations = mc.check(createEnv(), m);
+ assertTrue(violations.isEmpty());
+ }
+
// Encode a row how it would appear in Json
private static String encodeRowForMetadata(String row) {
try {