From 8521cb317811065a855c362634c184477813c7b3 Mon Sep 17 00:00:00 2001 From: Keith Turner Date: Fri, 19 Apr 2024 07:40:49 -0700 Subject: [PATCH] improves efficiency of migration set clean up (#4474) Cleanup of the set of migrating tablets would read the entire metadata table and read all tablet extents into memory. This changes limits the scan to the tablets section of the metadata table and avoids reading all tablet extents into memory. --- .../java/org/apache/accumulo/manager/Manager.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/Manager.java b/server/manager/src/main/java/org/apache/accumulo/manager/Manager.java index b81e0c74564..3467bea76d0 100644 --- a/server/manager/src/main/java/org/apache/accumulo/manager/Manager.java +++ b/server/manager/src/main/java/org/apache/accumulo/manager/Manager.java @@ -95,6 +95,7 @@ import org.apache.accumulo.core.metadata.TabletLocationState; import org.apache.accumulo.core.metadata.TabletState; import org.apache.accumulo.core.metadata.schema.Ample.DataLevel; +import org.apache.accumulo.core.metadata.schema.MetadataSchema; import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.TabletColumnFamily; import org.apache.accumulo.core.metrics.MetricsUtil; import org.apache.accumulo.core.replication.thrift.ReplicationCoordinator; @@ -710,14 +711,17 @@ private void cleanupNonexistentMigrations(final AccumuloClient accumuloClient) throws TableNotFoundException { Scanner scanner = accumuloClient.createScanner(MetadataTable.NAME, Authorizations.EMPTY); TabletColumnFamily.PREV_ROW_COLUMN.fetch(scanner); - Set found = new HashSet<>(); + scanner.setRange(MetadataSchema.TabletsSection.getRange()); + Set notSeen; + synchronized (migrations) { + notSeen = new HashSet<>(migrations.keySet()); + } for (Entry entry : scanner) { KeyExtent extent = KeyExtent.fromMetaPrevRow(entry); - if (migrations.containsKey(extent)) { - found.add(extent); - } + notSeen.remove(extent); } - migrations.keySet().retainAll(found); + // remove tablets that used to be in migrations and were not seen in the metadata table + migrations.keySet().removeAll(notSeen); } /**