You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by dl...@apache.org on 2021/06/21 19:41:28 UTC
[accumulo] branch main updated: Cancel compactions when delete
table is called (#2169)
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 bb1ba1b Cancel compactions when delete table is called (#2169)
bb1ba1b is described below
commit bb1ba1be40409aab67ca26d7e167155e439feecf
Author: Dave Marion <dl...@apache.org>
AuthorDate: Mon Jun 21 15:41:18 2021 -0400
Cancel compactions when delete table is called (#2169)
Cancel user compactions in DeleteTable fate transaction
Reuse the ZooKeeper mutating code from CancelCompactions in
DeleteTable to cancel any user compactions on the table before
getting the write lock on the table.
Closes #2030
---
.../tableOps/compact/cancel/CancelCompactions.java | 21 +++++----
.../manager/tableOps/delete/DeleteTable.java | 14 ++++++
.../apache/accumulo/test/ExternalCompactionIT.java | 51 ++++++++++++++++++++++
3 files changed, 78 insertions(+), 8 deletions(-)
diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/compact/cancel/CancelCompactions.java b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/compact/cancel/CancelCompactions.java
index 4151aaa..95ba80f 100644
--- a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/compact/cancel/CancelCompactions.java
+++ b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/compact/cancel/CancelCompactions.java
@@ -54,6 +54,19 @@ public class CancelCompactions extends ManagerRepo {
@Override
public Repo<Manager> call(long tid, Manager environment) throws Exception {
+
+ mutateZooKeeper(tid, tableId, environment);
+ return new FinishCancelCompaction(namespaceId, tableId);
+ }
+
+ @Override
+ public void undo(long tid, Manager env) {
+ Utils.unreserveTable(env, tableId, tid, false);
+ Utils.unreserveNamespace(env, namespaceId, tid, false);
+ }
+
+ public static void mutateZooKeeper(long tid, TableId tableId, Manager environment)
+ throws Exception {
String zCompactID = Constants.ZROOT + "/" + environment.getInstanceID() + Constants.ZTABLES
+ "/" + tableId + Constants.ZTABLE_COMPACT_ID;
String zCancelID = Constants.ZROOT + "/" + environment.getInstanceID() + Constants.ZTABLES + "/"
@@ -80,13 +93,5 @@ public class CancelCompactions extends ManagerRepo {
return Long.toString(cid).getBytes(UTF_8);
}
});
-
- return new FinishCancelCompaction(namespaceId, tableId);
- }
-
- @Override
- public void undo(long tid, Manager env) {
- Utils.unreserveTable(env, tableId, tid, false);
- Utils.unreserveNamespace(env, namespaceId, tid, false);
}
}
diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/DeleteTable.java b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/DeleteTable.java
index 2156663..c292425 100644
--- a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/DeleteTable.java
+++ b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/DeleteTable.java
@@ -26,6 +26,7 @@ import org.apache.accumulo.fate.Repo;
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.compact.cancel.CancelCompactions;
public class DeleteTable extends ManagerRepo {
@@ -41,6 +42,19 @@ public class DeleteTable extends ManagerRepo {
@Override
public long isReady(long tid, Manager env) throws Exception {
+
+ // Before attempting to delete the table, cancel any running user
+ // compactions.
+ if (Utils.reserveNamespace(env, namespaceId, tid, false, true, TableOperation.COMPACT_CANCEL)
+ + Utils.reserveTable(env, tableId, tid, false, true, TableOperation.COMPACT_CANCEL) == 0) {
+ try {
+ CancelCompactions.mutateZooKeeper(tid, tableId, env);
+ } finally {
+ Utils.unreserveTable(env, tableId, tid, false);
+ Utils.unreserveNamespace(env, namespaceId, tid, false);
+ }
+ }
+
return Utils.reserveNamespace(env, namespaceId, tid, false, false, TableOperation.DELETE)
+ Utils.reserveTable(env, tableId, tid, true, true, TableOperation.DELETE);
}
diff --git a/test/src/main/java/org/apache/accumulo/test/ExternalCompactionIT.java b/test/src/main/java/org/apache/accumulo/test/ExternalCompactionIT.java
index 311a287..b39098d 100644
--- a/test/src/main/java/org/apache/accumulo/test/ExternalCompactionIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/ExternalCompactionIT.java
@@ -680,6 +680,57 @@ public class ExternalCompactionIT extends SharedMiniClusterBase
}
@Test
+ public void testDeleteTableDuringUserExternalCompaction() throws Exception {
+ ProcessInfo c1 = null, coord = null;
+ try (AccumuloClient client = Accumulo.newClient()
+ .from(SharedMiniClusterBase.getCluster().getClientProperties()).build()) {
+
+ String table1 = "ectt6";
+ createTable(client, table1, "cs1");
+ writeData(client, table1);
+
+ // The ExternalDoNothingCompactor creates a compaction thread that
+ // sleeps for 5 minutes.
+ // Wait for the coordinator to insert the running compaction metadata
+ // entry into the metadata table, then cancel the compaction
+ c1 = SharedMiniClusterBase.getCluster().exec(ExternalDoNothingCompactor.class, "-q", "DCQ1");
+ coord = SharedMiniClusterBase.getCluster().exec(TestCompactionCoordinator.class);
+
+ compact(client, table1, 2, "DCQ1", false);
+
+ List<TabletMetadata> md = new ArrayList<>();
+ TabletsMetadata tm = getCluster().getServerContext().getAmple().readTablets()
+ .forLevel(DataLevel.USER).fetch(ColumnType.ECOMP).build();
+ tm.forEach(t -> md.add(t));
+
+ while (md.size() == 0) {
+ tm.close();
+ tm = getCluster().getServerContext().getAmple().readTablets().forLevel(DataLevel.USER)
+ .fetch(ColumnType.ECOMP).build();
+ tm.forEach(t -> md.add(t));
+ }
+
+ assertEquals(0, getCoordinatorMetrics().getFailed());
+
+ client.tableOperations().delete(table1);
+
+ // wait for failure or test timeout
+ ExternalCompactionMetrics metrics = getCoordinatorMetrics();
+ while (metrics.getFailed() == 0) {
+ UtilWaitThread.sleep(250);
+ metrics = getCoordinatorMetrics();
+ }
+
+ assertEquals(1, metrics.getStarted());
+ assertEquals(0, metrics.getRunning());
+ assertEquals(0, metrics.getCompleted());
+ assertEquals(1, metrics.getFailed());
+ } finally {
+ stopProcesses(c1, coord);
+ }
+ }
+
+ @Test
public void testDeleteTableDuringExternalCompaction() throws Exception {
ProcessInfo c1 = null, coord = null;
String table1 = this.getUniqueNames(1)[0];