This is an automated email from the ASF dual-hosted git repository.
dlmarion 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 f2cd46bd9a Log details of key violating DefaultKeySizeConstraint
(#5924)
f2cd46bd9a is described below
commit f2cd46bd9a65527ee90ad0aa1d13a4880c1e1ff7
Author: Dave Marion <[email protected]>
AuthorDate: Fri Sep 26 07:48:49 2025 -0400
Log details of key violating DefaultKeySizeConstraint (#5924)
Closes #5915
---
.../core/constraints/DefaultKeySizeConstraint.java | 42 +++-------------------
.../java/org/apache/accumulo/core/data/Key.java | 2 +-
.../data/constraints/DefaultKeySizeConstraint.java | 7 ++++
3 files changed, 13 insertions(+), 38 deletions(-)
diff --git
a/core/src/main/java/org/apache/accumulo/core/constraints/DefaultKeySizeConstraint.java
b/core/src/main/java/org/apache/accumulo/core/constraints/DefaultKeySizeConstraint.java
index 0c09b4678f..aeed9caa8a 100644
---
a/core/src/main/java/org/apache/accumulo/core/constraints/DefaultKeySizeConstraint.java
+++
b/core/src/main/java/org/apache/accumulo/core/constraints/DefaultKeySizeConstraint.java
@@ -18,10 +18,8 @@
*/
package org.apache.accumulo.core.constraints;
-import java.util.ArrayList;
import java.util.List;
-import org.apache.accumulo.core.data.ColumnUpdate;
import org.apache.accumulo.core.data.Mutation;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@@ -38,43 +36,13 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
public class DefaultKeySizeConstraint extends
org.apache.accumulo.core.data.constraints.DefaultKeySizeConstraint
implements Constraint {
- protected static final short MAX__KEY_SIZE_EXCEEDED_VIOLATION = 1;
- protected static final long maxSize = 1048576; // 1MB default size
-
- @Override
- public String getViolationDescription(short violationCode) {
-
- switch (violationCode) {
- case MAX__KEY_SIZE_EXCEEDED_VIOLATION:
- return "Key was larger than 1MB";
- }
-
- return null;
- }
-
- static final List<Short> NO_VIOLATIONS = new ArrayList<>();
+ protected static final short MAX__KEY_SIZE_EXCEEDED_VIOLATION =
+
org.apache.accumulo.core.data.constraints.DefaultKeySizeConstraint.MAX__KEY_SIZE_EXCEEDED_VIOLATION;
+ protected static final long maxSize =
+
org.apache.accumulo.core.data.constraints.DefaultKeySizeConstraint.maxSize;
@Override
public List<Short> check(Constraint.Environment env, Mutation mutation) {
-
- // fast size check
- if (mutation.numBytes() < maxSize) {
- return NO_VIOLATIONS;
- }
-
- List<Short> violations = new ArrayList<>();
-
- for (ColumnUpdate cu : mutation.getUpdates()) {
- int size = mutation.getRow().length;
- size += cu.getColumnFamily().length;
- size += cu.getColumnQualifier().length;
- size += cu.getColumnVisibility().length;
-
- if (size > maxSize) {
- violations.add(MAX__KEY_SIZE_EXCEEDED_VIOLATION);
- }
- }
-
- return violations;
+ return super.check(env, mutation);
}
}
diff --git a/core/src/main/java/org/apache/accumulo/core/data/Key.java
b/core/src/main/java/org/apache/accumulo/core/data/Key.java
index 147d412ce8..95ee6da5f6 100644
--- a/core/src/main/java/org/apache/accumulo/core/data/Key.java
+++ b/core/src/main/java/org/apache/accumulo/core/data/Key.java
@@ -1058,7 +1058,7 @@ public class Key implements WritableComparable<Key>,
Cloneable {
}
if (len > maxLen) {
- sb.append("... TRUNCATED");
+ sb.append("... TRUNCATED (length: ").append(len).append(")");
}
return sb;
diff --git
a/core/src/main/java/org/apache/accumulo/core/data/constraints/DefaultKeySizeConstraint.java
b/core/src/main/java/org/apache/accumulo/core/data/constraints/DefaultKeySizeConstraint.java
index f81ff133b1..8f912dd48d 100644
---
a/core/src/main/java/org/apache/accumulo/core/data/constraints/DefaultKeySizeConstraint.java
+++
b/core/src/main/java/org/apache/accumulo/core/data/constraints/DefaultKeySizeConstraint.java
@@ -22,7 +22,10 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.accumulo.core.data.ColumnUpdate;
+import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Mutation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* A constraints that limits the size of keys to 1mb.
@@ -34,6 +37,7 @@ import org.apache.accumulo.core.data.Mutation;
*/
public class DefaultKeySizeConstraint implements Constraint {
+ private static final Logger LOG =
LoggerFactory.getLogger(DefaultKeySizeConstraint.class);
protected static final short MAX__KEY_SIZE_EXCEEDED_VIOLATION = 1;
protected static final long maxSize = 1048576; // 1MB default size
@@ -68,6 +72,9 @@ public class DefaultKeySizeConstraint implements Constraint {
if (size > maxSize) {
violations.add(MAX__KEY_SIZE_EXCEEDED_VIOLATION);
+ Key k = new Key(mutation.getRow(), cu.getColumnFamily(),
cu.getColumnQualifier(),
+ cu.getColumnVisibility(), cu.getTimestamp(), cu.isDeleted());
+ LOG.debug("Constraint violation. Key {} (size = {}) larger than 1MB",
k, size);
}
}