This is an automated email from the ASF dual-hosted git repository.

keith-turner 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 b5d6f1ccb3 Makes delete table always insert GC candidates (#6650)
b5d6f1ccb3 is described below

commit b5d6f1ccb35e338c544035ab5d5cc823ced9fa44
Author: Keith Turner <[email protected]>
AuthorDate: Mon Nov 16 11:15:50 2026 -0500

    Makes delete table always insert GC candidates (#6650)
    
    Removed code to directly delete a tables files in the delete table
    operation and instead always insert GC candidates.
    
    Fixes #6645
---
 .../org/apache/accumulo/core/conf/Property.java    |  9 ---
 .../accumulo/manager/tableOps/delete/CleanUp.java  | 73 +---------------------
 .../functional/DeleteAndVerifyFileRemovalsIT.java  | 46 +-------------
 3 files changed, 2 insertions(+), 126 deletions(-)

diff --git a/core/src/main/java/org/apache/accumulo/core/conf/Property.java 
b/core/src/main/java/org/apache/accumulo/core/conf/Property.java
index a70db83457..8f079542ed 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/Property.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/Property.java
@@ -457,15 +457,6 @@ public enum Property {
       "Time to wait between scanning tables to identify ranges of tablets that 
can be "
           + " auto-merged. Valid ranges will be have merge fate ops 
submitted.",
       "4.0.0"),
-  MANAGER_TABLE_DELETE_OPTIMIZATION("manager.table.delete.optimization", 
"true",
-      PropertyType.BOOLEAN,
-      "When deleting a table the Manager will remove related table directories 
from "
-          + " the storage volumes if there are no other references to the 
files in the "
-          + " metadata table. When deleting a lot of tables this optimization 
can be costly. "
-          + " Setting this value to false will skip this optimization and the 
table directory "
-          + " cleanup will occur in the Garbage Collector instead. The value 
should be false  "
-          + " when recursive deletes are not efficient on underlying volumes.",
-      "2.1.5"),
   MANAGER_BULK_TIMEOUT("manager.bulk.timeout", "5m", PropertyType.TIMEDURATION,
       "The time to wait for a tablet server to process a bulk import 
request.", "1.4.3"),
   MANAGER_RENAME_THREADS("manager.rename.threadpool.size", "20", 
PropertyType.COUNT,
diff --git 
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/CleanUp.java
 
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/CleanUp.java
index 8f628948c4..5aac8f879e 100644
--- 
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/CleanUp.java
+++ 
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/CleanUp.java
@@ -20,34 +20,16 @@ package org.apache.accumulo.manager.tableOps.delete;
 
 import static org.apache.accumulo.core.util.LazySingletons.GSON;
 
-import java.io.IOException;
-import java.net.UnknownHostException;
-import java.util.Arrays;
-import java.util.Map.Entry;
-
-import org.apache.accumulo.core.client.BatchScanner;
-import org.apache.accumulo.core.client.IteratorSetting;
 import org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException;
-import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.NamespaceId;
-import org.apache.accumulo.core.data.Range;
 import org.apache.accumulo.core.data.TableId;
-import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.fate.FateId;
 import org.apache.accumulo.core.fate.Repo;
 import 
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
-import org.apache.accumulo.core.iterators.user.GrepIterator;
-import org.apache.accumulo.core.metadata.SystemTables;
-import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection;
-import 
org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.DataFileColumnFamily;
-import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.manager.tableOps.AbstractFateOperation;
 import org.apache.accumulo.manager.tableOps.FateEnv;
 import org.apache.accumulo.manager.tableOps.Utils;
-import org.apache.accumulo.server.fs.VolumeManager;
 import org.apache.accumulo.server.util.MetadataTableUtil;
-import org.apache.hadoop.fs.Path;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -69,40 +51,6 @@ class CleanUp extends AbstractFateOperation {
 
   @Override
   public Repo<FateEnv> call(FateId fateId, FateEnv env) {
-    int refCount = 0;
-
-    if (!env.getContext().getConfiguration()
-        .getBoolean(Property.MANAGER_TABLE_DELETE_OPTIMIZATION)) {
-      // Skip scanning the metadata table for each table delete and always 
allow the GC to handle
-      // file deletion.
-      refCount = -1;
-    } else {
-      // look for other tables that references this table's files
-      try (BatchScanner bs = 
env.getContext().createBatchScanner(SystemTables.METADATA.tableName(),
-          Authorizations.EMPTY, 8)) {
-        Range allTables = TabletsSection.getRange();
-        Range tableRange = TabletsSection.getRange(tableId);
-        Range beforeTable =
-            new Range(allTables.getStartKey(), true, tableRange.getStartKey(), 
false);
-        Range afterTable = new Range(tableRange.getEndKey(), false, 
allTables.getEndKey(), true);
-        bs.setRanges(Arrays.asList(beforeTable, afterTable));
-        bs.fetchColumnFamily(DataFileColumnFamily.NAME);
-        IteratorSetting cfg = new IteratorSetting(40, "grep", 
GrepIterator.class);
-        GrepIterator.setTerm(cfg, "/" + tableId + "/");
-        bs.addScanIterator(cfg);
-
-        for (Entry<Key,Value> entry : bs) {
-          if (entry.getKey().getColumnQualifier().toString().contains("/" + 
tableId + "/")) {
-            refCount = 1;
-            break;
-          }
-        }
-      } catch (Exception e) {
-        refCount = -1;
-        log.error("Failed to scan {} looking for references to deleted table 
{}",
-            SystemTables.METADATA.tableName(), tableId, e);
-      }
-    }
 
     // remove metadata table entries
     try {
@@ -111,30 +59,11 @@ class CleanUp extends AbstractFateOperation {
       // If the manager lock passed to deleteTable, it is possible that the 
delete mutations will be
       // dropped. If the delete operations
       // are dropped and the operation completes, then the deletes will not be 
repeated.
-      MetadataTableUtil.deleteTable(tableId, refCount != 0, env.getContext(), 
null);
+      MetadataTableUtil.deleteTable(tableId, true, env.getContext(), null);
     } catch (Exception e) {
       log.error("error deleting {} from metadata table", tableId, e);
     }
 
-    if (refCount == 0) {
-      // delete the data files
-      try {
-        VolumeManager fs = env.getVolumeManager();
-        for (String dir : env.getContext().getTablesDirs()) {
-          fs.deleteRecursively(new Path(dir, tableId.canonical()));
-        }
-      } catch (IOException e) {
-        log.error("Unable to remove deleted table directory", e);
-      } catch (IllegalArgumentException exception) {
-        if (exception.getCause() instanceof UnknownHostException) {
-          /* Thrown if HDFS encounters a DNS problem in some edge cases */
-          log.error("Unable to remove deleted table directory", exception);
-        } else {
-          throw exception;
-        }
-      }
-    }
-
     // remove table from zookeeper
     try {
       env.getTableManager().removeTable(tableId, namespaceId);
diff --git 
a/test/src/main/java/org/apache/accumulo/test/functional/DeleteAndVerifyFileRemovalsIT.java
 
b/test/src/main/java/org/apache/accumulo/test/functional/DeleteAndVerifyFileRemovalsIT.java
index efe89a75d7..4a038800bc 100644
--- 
a/test/src/main/java/org/apache/accumulo/test/functional/DeleteAndVerifyFileRemovalsIT.java
+++ 
b/test/src/main/java/org/apache/accumulo/test/functional/DeleteAndVerifyFileRemovalsIT.java
@@ -18,7 +18,6 @@
  */
 package org.apache.accumulo.test.functional;
 
-import static 
org.apache.accumulo.core.conf.Property.MANAGER_TABLE_DELETE_OPTIMIZATION;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -74,49 +73,7 @@ public class DeleteAndVerifyFileRemovalsIT extends 
ConfigurableMacBase {
   }
 
   /**
-   * Verify that a table's HDFS directory and all of its RFiles are eventually 
removed after a
-   * delete operation.
-   */
-  @Test
-  public void testManagerRemovesFilesOnTableDelete() throws Exception {
-    // Stop the GC so gcCandidates persist if created.
-    getCluster().getClusterControl().stop(ServerType.GARBAGE_COLLECTOR);
-
-    try (AccumuloClient client = 
Accumulo.newClient().from(getClientProperties()).build()) {
-      final String tableName = getUniqueNames(1)[0];
-      client.tableOperations().create(tableName,
-          new NewTableConfiguration().withSplits(new TreeSet<>(List.of(new 
Text("row000099")))));
-      writeAndFlush(client, tableName, 200);
-
-      final TableId tableId = 
TableId.of(client.tableOperations().tableIdMap().get(tableName));
-
-      final FileSystem fs = getCluster().getFileSystem();
-      final Path tableDir = returnTableHdfsDir(tableId);
-
-      // Verify that no GC deletion markers currently exist
-      assertTrue(countGcCandidates(tableId, 0), "GcCandidates should not 
exist");
-
-      assertTrue(fs.exists(tableDir),
-          "Table HDFS directory must exist before deleting: " + tableDir);
-      assertTrue(hasRFiles(fs, tableDir, 2), "Two files must exist before 
deleting: " + tableDir);
-
-      client.tableOperations().delete(tableName);
-
-      // Verify that no GC deletion markers were created
-      assertTrue(countGcCandidates(tableId, 0), "GcCandidates should not 
exist");
-
-      Wait.waitFor(() -> !fs.exists(tableDir), GC_MAX_WAIT, POLLING_WAIT,
-          "Table HDFS directory must be removed after delete: " + tableDir);
-
-      assertFalse(fs.exists(tableDir),
-          "Table HDFS directory still exists after Manager deleted volumes for 
" + tableDir);
-    }
-  }
-
-  /**
-   * Verify that when {@link Property#MANAGER_TABLE_DELETE_OPTIMIZATION} is 
set to {@code false},
-   * the manager skips the metadata table scan and writes gcCandidates. The GC 
is then responsible
-   * for file deletion.
+   * Verify the manager writes gcCandidates. The GC is then responsible for 
file deletion.
    */
   @Test
   public void testManagerCreatesGcCandidatesOnTableDelete() throws Exception {
@@ -124,7 +81,6 @@ public class DeleteAndVerifyFileRemovalsIT extends 
ConfigurableMacBase {
     getCluster().getClusterControl().stop(ServerType.GARBAGE_COLLECTOR);
 
     try (AccumuloClient client = 
Accumulo.newClient().from(getClientProperties()).build()) {
-      
client.instanceOperations().setProperty(MANAGER_TABLE_DELETE_OPTIMIZATION.getKey(),
 "false");
 
       final String tableName = getUniqueNames(1)[0];
       client.tableOperations().create(tableName,

Reply via email to