From 809889044c82413e0675984ca34608e09414c57b Mon Sep 17 00:00:00 2001 From: Dave Marion Date: Wed, 18 Oct 2023 21:29:48 +0000 Subject: [PATCH] Allow null prevEndRow for creating a tablet in split --- .../ConditionalTabletMutatorImpl.java | 21 +++++++++++++++---- .../manager/tableOps/split/UpdateTablets.java | 3 +-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/server/base/src/main/java/org/apache/accumulo/server/metadata/ConditionalTabletMutatorImpl.java b/server/base/src/main/java/org/apache/accumulo/server/metadata/ConditionalTabletMutatorImpl.java index e6d17e543f9..c3386fbf496 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/metadata/ConditionalTabletMutatorImpl.java +++ b/server/base/src/main/java/org/apache/accumulo/server/metadata/ConditionalTabletMutatorImpl.java @@ -68,12 +68,14 @@ public class ConditionalTabletMutatorImpl extends TabletMutatorBase mutationConsumer; private final Ample.ConditionalTabletsMutator parent; + private final boolean prevEndRowSupplied; private final BiConsumer rejectionHandlerConsumer; private final KeyExtent extent; private boolean sawOperationRequirement = false; + private boolean requireAbsentTabletCalled = false; protected ConditionalTabletMutatorImpl(Ample.ConditionalTabletsMutator parent, ServerContext context, KeyExtent extent, Text prevEndRow, @@ -86,10 +88,17 @@ protected ConditionalTabletMutatorImpl(Ample.ConditionalTabletsMutator parent, this.rejectionHandlerConsumer = rejectionHandlerConsumer; this.extent = extent; - Condition c = - new Condition(PREV_ROW_COLUMN.getColumnFamily(), PREV_ROW_COLUMN.getColumnQualifier()) - .setValue(TabletColumnFamily.encodePrevEndRow(prevEndRow).get()); - mutation.addCondition(c); + // If prevEndRow is null, then we are creating a new Tablet in which case + // there is no prevEndRow. + if (prevEndRow != null) { + Condition c = + new Condition(PREV_ROW_COLUMN.getColumnFamily(), PREV_ROW_COLUMN.getColumnQualifier()) + .setValue(TabletColumnFamily.encodePrevEndRow(prevEndRow).get()); + mutation.addCondition(c); + prevEndRowSupplied = true; + } else { + prevEndRowSupplied = false; + } } @Override @@ -139,6 +148,7 @@ public Ample.ConditionalTabletMutator requireAbsentTablet() { Condition c = new Condition("", "").setIterators(is); mutation.addCondition(c); sawOperationRequirement = true; + requireAbsentTabletCalled = true; return this; } @@ -244,6 +254,9 @@ public Ample.ConditionalTabletMutator requireSame(TabletMetadata tabletMetadata, public void submit(Ample.RejectionHandler rejectionCheck) { Preconditions.checkState(updatesEnabled, "Cannot make updates after calling mutate."); Preconditions.checkState(sawOperationRequirement, "No operation requirements were seen"); + if (!prevEndRowSupplied && !requireAbsentTabletCalled) { + requireAbsentTablet(); + } getMutation(); mutationConsumer.accept(mutation); rejectionHandlerConsumer.accept(extent, rejectionCheck); diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/split/UpdateTablets.java b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/split/UpdateTablets.java index c6310204671..8613a10520b 100644 --- a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/split/UpdateTablets.java +++ b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/split/UpdateTablets.java @@ -177,8 +177,7 @@ private void addNewTablets(long tid, Manager manager, TabletMetadata tabletMetad continue; } - var mutator = - tabletsMutator.mutateTablet(newExtent, newExtent.prevEndRow()).requireAbsentTablet(); + var mutator = tabletsMutator.mutateTablet(newExtent, null).requireAbsentTablet(); mutator.putOperation(opid); mutator.putDirName(dirNameIter.next());