[accumulo] branch main updated: Prevent compactions from starting when deleting a table

2021-09-07 Thread dlmarion
This is an automated email from the ASF dual-hosted git repository.

dlmarion 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 7011224  Prevent compactions from starting when deleting a table
7011224 is described below

commit 70112240c5a36f5a146d8ecafa322cd7d94cd387
Author: Dave Marion 
AuthorDate: Tue Sep 7 13:00:19 2021 -0400

Prevent compactions from starting when deleting a table

Closes #2182
---
 .../java/org/apache/accumulo/core/Constants.java   |   1 +
 .../manager/tableOps/compact/CompactionDriver.java |  18 ++-
 .../manager/tableOps/delete/PreDeleteTable.java|  17 +++
 .../tableOps/compact/CompactionDriverTest.java | 124 +
 4 files changed, 157 insertions(+), 3 deletions(-)

diff --git a/core/src/main/java/org/apache/accumulo/core/Constants.java 
b/core/src/main/java/org/apache/accumulo/core/Constants.java
index a46803f..b96c8a9 100644
--- a/core/src/main/java/org/apache/accumulo/core/Constants.java
+++ b/core/src/main/java/org/apache/accumulo/core/Constants.java
@@ -38,6 +38,7 @@ public class Constants {
   public static final String ZTABLES = "/tables";
   public static final byte[] ZTABLES_INITIAL_ID = {'0'};
   public static final String ZTABLE_NAME = "/name";
+  public static final String ZTABLE_DELETE_MARKER = "/deleting";
   public static final String ZTABLE_CONF = "/conf";
   public static final String ZTABLE_STATE = "/state";
   public static final String ZTABLE_FLUSH_ID = "/flush-id";
diff --git 
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/compact/CompactionDriver.java
 
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/compact/CompactionDriver.java
index 00eaf94..24a5f62 100644
--- 
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/compact/CompactionDriver.java
+++ 
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/compact/CompactionDriver.java
@@ -40,12 +40,18 @@ import org.apache.accumulo.fate.zookeeper.ZooReaderWriter;
 import org.apache.accumulo.manager.Manager;
 import org.apache.accumulo.manager.tableOps.ManagerRepo;
 import org.apache.accumulo.manager.tableOps.Utils;
+import org.apache.accumulo.manager.tableOps.delete.PreDeleteTable;
 import org.apache.accumulo.server.manager.LiveTServerSet.TServerConnection;
 import org.apache.thrift.TException;
 import org.slf4j.LoggerFactory;
 
 class CompactionDriver extends ManagerRepo {
 
+  public static String createCompactionCancellationPath(String instanceId, 
TableId tableId) {
+return Constants.ZROOT + "/" + instanceId + Constants.ZTABLES + "/" + 
tableId.canonical()
++ Constants.ZTABLE_COMPACT_CANCEL_ID;
+  }
+
   private static final long serialVersionUID = 1L;
 
   private long compactId;
@@ -71,9 +77,7 @@ class CompactionDriver extends ManagerRepo {
   return 0;
 }
 
-String zCancelID = Constants.ZROOT + "/" + manager.getInstanceID() + 
Constants.ZTABLES + "/"
-+ tableId + Constants.ZTABLE_COMPACT_CANCEL_ID;
-
+String zCancelID = 
createCompactionCancellationPath(manager.getInstanceID(), tableId);
 ZooReaderWriter zoo = manager.getContext().getZooReaderWriter();
 
 if (Long.parseLong(new String(zoo.getData(zCancelID))) >= compactId) {
@@ -82,6 +86,14 @@ class CompactionDriver extends ManagerRepo {
   TableOperation.COMPACT, TableOperationExceptionType.OTHER, 
"Compaction canceled");
 }
 
+String deleteMarkerPath =
+PreDeleteTable.createDeleteMarkerPath(manager.getInstanceID(), 
tableId);
+if (zoo.exists(deleteMarkerPath)) {
+  // table is being deleted
+  throw new AcceptableThriftTableOperationException(tableId.canonical(), 
null,
+  TableOperation.COMPACT, TableOperationExceptionType.OTHER, "Table is 
being deleted");
+}
+
 MapCounter serversToFlush = new MapCounter<>();
 long t1 = System.currentTimeMillis();
 
diff --git 
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/PreDeleteTable.java
 
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/PreDeleteTable.java
index a88bb5e..ac39708 100644
--- 
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/PreDeleteTable.java
+++ 
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/PreDeleteTable.java
@@ -18,17 +18,26 @@
  */
 package org.apache.accumulo.manager.tableOps.delete;
 
+import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.clientImpl.thrift.TableOperation;
 import org.apache.accumulo.core.data.NamespaceId;
 import org.apache.accumulo.core.data.TableId;
 import org.apache.accumulo.fate.Repo;
+import org.apache.accumulo.fate.zookeeper.ZooReaderWriter;
+import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
 import org.apache.accumulo.manager.Manager;
 import org.apache.accumulo.manager.tableOps.ManagerRepo;
 

[accumulo] branch main updated: Add check for deleted Table to Tablet compactAll (#2262)

2021-09-07 Thread mmiller
This is an automated email from the ASF dual-hosted git repository.

mmiller 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 68ca8c1  Add check for deleted Table to Tablet compactAll (#2262)
68ca8c1 is described below

commit 68ca8c1c584d7987602a8c1dd901c45d0f9cd7ad
Author: Mike Miller 
AuthorDate: Tue Sep 7 09:47:07 2021 -0400

Add check for deleted Table to Tablet compactAll (#2262)

* Also drop unnecessary boolean and add comment
---
 .../main/java/org/apache/accumulo/tserver/tablet/Tablet.java | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git 
a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java 
b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
index 360ac77..709ed43 100644
--- 
a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
+++ 
b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
@@ -2096,8 +2096,6 @@ public class Tablet {
 
   public void compactAll(long compactionId, CompactionConfig compactionConfig) 
{
 
-boolean shouldInitiate = false;
-
 synchronized (this) {
   if (lastCompactID >= compactionId) {
 return;
@@ -2116,17 +2114,13 @@ public class Tablet {
 }
   }
 
-  if (isClosing() || isClosed()) {
+  if (isClosing() || isClosed() || isBeingDeleted()) {
 return;
   }
-
-  shouldInitiate = true;
-
 }
 
-if (shouldInitiate) {
-  compactable.initiateUserCompaction(compactionId, compactionConfig);
-}
+// passed all verification checks so initiate compaction
+compactable.initiateUserCompaction(compactionId, compactionConfig);
   }
 
   public TableConfiguration getTableConfiguration() {