Skip to content

Commit 304f52c

Browse files
committed
Merge branch '2.1'
2 parents aab373f + 9961765 commit 304f52c

4 files changed

Lines changed: 417 additions & 15 deletions

File tree

core/src/main/java/org/apache/accumulo/core/conf/Property.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,14 @@ are performed (e.g. Bulk Import). This property specifies the maximum number of
441441
"Time to wait between scanning tables to identify ranges of tablets that can be "
442442
+ " auto-merged. Valid ranges will be have merge fate ops submitted.",
443443
"4.0.0"),
444+
MANAGER_TABLE_DELETE_OPTIMIZATION("manager.table.delete.optimization", "true",
445+
PropertyType.BOOLEAN,
446+
"When deleting a table the Manager will remove related table directories from "
447+
+ " the storage volumes if there are no other references to the files in the "
448+
+ " metadata table. When deleting a lot of tables this optimization can be costly. "
449+
+ " Setting this value to false will skip this optimization and the table directory "
450+
+ " cleanup will occur in the Garbage Collector instead.",
451+
"2.1.5"),
444452
MANAGER_BULK_TIMEOUT("manager.bulk.timeout", "5m", PropertyType.TIMEDURATION,
445453
"The time to wait for a tablet server to process a bulk import request.", "1.4.3"),
446454
MANAGER_RENAME_THREADS("manager.rename.threadpool.size", "20", PropertyType.COUNT,

server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public static void deleteTable(TableId tableId, boolean insertDeletes, ServerCon
110110
Ample ample = context.getAmple();
111111
ms.setRange(new KeyExtent(tableId, null, null).toMetaRange());
112112

113-
// insert deletes before deleting data from metadata... this makes the code fault tolerant
113+
// insert deletes before deleting data from metadata... this makes the code fault-tolerant
114114
if (insertDeletes) {
115115

116116
ms.fetchColumnFamily(DataFileColumnFamily.NAME);

server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/CleanUp.java

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
import java.util.Arrays;
2424
import java.util.Map.Entry;
2525

26-
import org.apache.accumulo.core.client.AccumuloClient;
2726
import org.apache.accumulo.core.client.BatchScanner;
2827
import org.apache.accumulo.core.client.IteratorSetting;
2928
import org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException;
29+
import org.apache.accumulo.core.conf.Property;
3030
import org.apache.accumulo.core.data.Key;
3131
import org.apache.accumulo.core.data.NamespaceId;
3232
import org.apache.accumulo.core.data.Range;
@@ -67,11 +67,15 @@ public CleanUp(TableId tableId, NamespaceId namespaceId) {
6767
public Repo<FateEnv> call(FateId fateId, FateEnv env) {
6868
int refCount = 0;
6969

70-
try {
70+
if (!env.getContext().getConfiguration()
71+
.getBoolean(Property.MANAGER_TABLE_DELETE_OPTIMIZATION)) {
72+
// Skip scanning the metadata table for each table delete and always allow the GC to handle
73+
// file deletion.
74+
refCount = -1;
75+
} else {
7176
// look for other tables that references this table's files
72-
AccumuloClient client = env.getContext();
73-
try (BatchScanner bs =
74-
client.createBatchScanner(SystemTables.METADATA.tableName(), Authorizations.EMPTY, 8)) {
77+
try (BatchScanner bs = env.getContext().createBatchScanner(SystemTables.METADATA.tableName(),
78+
Authorizations.EMPTY, 8)) {
7579
Range allTables = TabletsSection.getRange();
7680
Range tableRange = TabletsSection.getRange(tableId);
7781
Range beforeTable =
@@ -85,15 +89,15 @@ public Repo<FateEnv> call(FateId fateId, FateEnv env) {
8589

8690
for (Entry<Key,Value> entry : bs) {
8791
if (entry.getKey().getColumnQualifier().toString().contains("/" + tableId + "/")) {
88-
refCount++;
92+
refCount = 1;
93+
break;
8994
}
9095
}
96+
} catch (Exception e) {
97+
refCount = -1;
98+
log.error("Failed to scan {} looking for references to deleted table {}",
99+
SystemTables.METADATA.tableName(), tableId, e);
91100
}
92-
93-
} catch (Exception e) {
94-
refCount = -1;
95-
log.error("Failed to scan " + SystemTables.METADATA.tableName()
96-
+ " looking for references to deleted table " + tableId, e);
97101
}
98102

99103
// remove metadata table entries
@@ -105,7 +109,7 @@ public Repo<FateEnv> call(FateId fateId, FateEnv env) {
105109
// are dropped and the operation completes, then the deletes will not be repeated.
106110
MetadataTableUtil.deleteTable(tableId, refCount != 0, env.getContext(), null);
107111
} catch (Exception e) {
108-
log.error("error deleting " + tableId + " from metadata table", e);
112+
log.error("error deleting {} from metadata table", tableId, e);
109113
}
110114

111115
if (refCount == 0) {
@@ -132,7 +136,7 @@ public Repo<FateEnv> call(FateId fateId, FateEnv env) {
132136
env.getTableManager().removeTable(tableId, namespaceId);
133137
env.getContext().clearTableListCache();
134138
} catch (Exception e) {
135-
log.error("Failed to find table id in zookeeper", e);
139+
log.error("Failed to find table id {} in zookeeper", tableId, e);
136140
}
137141

138142
// remove any permissions associated with this table
@@ -146,7 +150,7 @@ public Repo<FateEnv> call(FateId fateId, FateEnv env) {
146150
Utils.unreserveTable(env.getContext(), tableId, fateId, LockType.WRITE);
147151
Utils.unreserveNamespace(env.getContext(), namespaceId, fateId, LockType.READ);
148152

149-
LoggerFactory.getLogger(CleanUp.class).debug("Deleted table " + tableId);
153+
log.debug("Deleted table {}", tableId);
150154

151155
return null;
152156
}

0 commit comments

Comments
 (0)