ctubbsii commented on a change in pull request #2175: URL: https://github.com/apache/accumulo/pull/2175#discussion_r659884273
########## 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: I think we still need to unreserve the read lock acquired, even on success, before we enter the DeleteTable repo: ```suggestion CancelCompactions.mutateZooKeeper(tid, tableId, environment); Utils.unreserveTable(env, tableId, tid, false); Utils.unreserveNamespace(env, namespaceId, tid, false); return new DeleteTable(namespaceId, tableId); ``` ########## 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'm not sure it would have mattered to put it in a try-finally block, because if there was an exception in this, it would have triggered the FaTE operation's `undo` or it would have retried. But, I don't think it hurts. ########## 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: Created follow-up issue for this in #2182 -- 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]
