dlmarion commented on a change in pull request #2175:
URL: https://github.com/apache/accumulo/pull/2175#discussion_r659848138



##########
File path: 
server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/PreDeleteTable.java
##########
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.accumulo.manager.tableOps.delete;
+
+import org.apache.accumulo.core.data.NamespaceId;
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.fate.Repo;
+import org.apache.accumulo.manager.Manager;
+import org.apache.accumulo.manager.tableOps.compact.cancel.CancelCompactions;
+
+public class PreDeleteTable extends CancelCompactions {

Review comment:
       I modified PreDeleteTable to extend ManagerRepo instead of 
CancelCompactions in 6c65c0d2113ef16bfc086de3e7e996b05d97d6f9

##########
File path: 
server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/DeleteTable.java
##########
@@ -43,8 +43,13 @@ public DeleteTable(NamespaceId namespaceId, TableId tableId) 
{
   @Override
   public long isReady(long tid, Manager env) throws Exception {
 
-    // Before attempting to delete the table, cancel any running user
-    // compactions.
+    // If we have the table write lock, then it's possible that we have
+    // already canceled the compactions and we can skip to deleting the tables.
+    if (Utils.hasNamespaceReadLock(env, namespaceId, tid)
+        && Utils.hasTableWriteLock(env, tableId, tid)) {
+      return 0;
+    }
+    // Cancel any running user compactions before deleting table
     if (Utils.reserveNamespace(env, namespaceId, tid, false, true, 
TableOperation.COMPACT_CANCEL)

Review comment:
       I would like to leave the compaction id changes to a different issue, 
mainly because I'm not comfortable enough with the code.

##########
File path: 
server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/PreDeleteTable.java
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.accumulo.manager.tableOps.delete;
+
+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.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 PreDeleteTable extends ManagerRepo {
+
+  private static final long serialVersionUID = 1L;
+
+  private TableId tableId;
+  private NamespaceId namespaceId;
+
+  public PreDeleteTable(NamespaceId namespaceId, TableId tableId) {
+    this.tableId = tableId;
+    this.namespaceId = namespaceId;
+  }
+
+  @Override
+  public long isReady(long tid, Manager env) throws Exception {
+    return Utils.reserveNamespace(env, namespaceId, tid, false, true, 
TableOperation.DELETE)
+        + Utils.reserveTable(env, tableId, tid, false, true, 
TableOperation.DELETE);
+  }
+
+  @Override
+  public Repo<Manager> call(long tid, Manager environment) throws Exception {
+    CancelCompactions.mutateZooKeeper(tid, tableId, environment);
+    return new DeleteTable(namespaceId, tableId);

Review comment:
       Good catch. Working too many things...

##########
File path: 
server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/PreDeleteTable.java
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.accumulo.manager.tableOps.delete;
+
+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.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 PreDeleteTable extends ManagerRepo {
+
+  private static final long serialVersionUID = 1L;
+
+  private TableId tableId;
+  private NamespaceId namespaceId;
+
+  public PreDeleteTable(NamespaceId namespaceId, TableId tableId) {
+    this.tableId = tableId;
+    this.namespaceId = namespaceId;
+  }
+
+  @Override
+  public long isReady(long tid, Manager env) throws Exception {
+    return Utils.reserveNamespace(env, namespaceId, tid, false, true, 
TableOperation.DELETE)
+        + Utils.reserveTable(env, tableId, tid, false, true, 
TableOperation.DELETE);
+  }
+
+  @Override
+  public Repo<Manager> call(long tid, Manager environment) throws Exception {
+    CancelCompactions.mutateZooKeeper(tid, tableId, environment);
+    return new DeleteTable(namespaceId, tableId);

Review comment:
       Fixed in e50c258

##########
File path: 
server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/PreDeleteTable.java
##########
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.accumulo.manager.tableOps.delete;
+
+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.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 PreDeleteTable extends ManagerRepo {
+
+  private static final long serialVersionUID = 1L;
+
+  private TableId tableId;
+  private NamespaceId namespaceId;
+
+  public PreDeleteTable(NamespaceId namespaceId, TableId tableId) {
+    this.tableId = tableId;
+    this.namespaceId = namespaceId;
+  }
+
+  @Override
+  public long isReady(long tid, Manager env) throws Exception {
+    return Utils.reserveNamespace(env, namespaceId, tid, false, true, 
TableOperation.DELETE)
+        + Utils.reserveTable(env, tableId, tid, false, true, 
TableOperation.DELETE);
+  }
+
+  @Override
+  public Repo<Manager> call(long tid, Manager environment) throws Exception {
+    try {
+      CancelCompactions.mutateZooKeeper(tid, tableId, environment);
+      return new DeleteTable(namespaceId, tableId);
+    } finally {
+      Utils.unreserveTable(environment, tableId, tid, false);
+      Utils.unreserveNamespace(environment, namespaceId, tid, false);
+    }

Review comment:
       I agree that it doesn't hurt. I did look into whether or not having the 
`unreserve` methods called twice would be an issue and I came to the conclusion 
that it would not.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to