2323import java .util .Arrays ;
2424import java .util .Map .Entry ;
2525
26- import org .apache .accumulo .core .client .AccumuloClient ;
2726import org .apache .accumulo .core .client .BatchScanner ;
2827import org .apache .accumulo .core .client .IteratorSetting ;
2928import org .apache .accumulo .core .clientImpl .thrift .ThriftSecurityException ;
29+ import org .apache .accumulo .core .conf .Property ;
3030import org .apache .accumulo .core .data .Key ;
3131import org .apache .accumulo .core .data .NamespaceId ;
3232import 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