keith-turner commented on code in PR #4668:
URL: https://github.com/apache/accumulo/pull/4668#discussion_r1638778224
##########
server/manager/src/main/java/org/apache/accumulo/manager/TabletGroupWatcher.java:
##########
@@ -876,61 +853,53 @@ private void cancelOfflineTableMigrations(KeyExtent
extent) {
}
}
- private void repairMetadata(Text row) {
- Manager.log.debug("Attempting repair on {}", row);
- // ACCUMULO-2261 if a dying tserver writes a location before its lock
information propagates, it
- // may cause duplicate assignment.
- // Attempt to find the dead server entry and remove it.
+ private void logIncorrectTabletLocations(TabletMetadata tabletMetadata) {
try {
Map<Key,Value> future = new HashMap<>();
Map<Key,Value> assigned = new HashMap<>();
- KeyExtent extent = KeyExtent.fromMetaRow(row);
- String table = AccumuloTable.METADATA.tableName();
- if (extent.isMeta()) {
- table = AccumuloTable.ROOT.tableName();
+ KeyExtent extent = tabletMetadata.getExtent();
+ var level = Ample.DataLevel.of(extent.tableId());
+
+ Stream<? extends Entry<Key,Value>> entries;
+ if (level == Ample.DataLevel.ROOT) {
+ RootTabletMetadata rtm = RootTabletMetadata.read(manager.getContext());
+ entries = rtm.getKeyValues();
+ } else {
+ Scanner scanner =
+ manager.getContext().createScanner(level.metaTable(),
Authorizations.EMPTY);
+ scanner.fetchColumnFamily(CurrentLocationColumnFamily.NAME);
+ scanner.fetchColumnFamily(FutureLocationColumnFamily.NAME);
+ scanner.setRange(new Range(extent.toMetaRow()));
+ entries = scanner.stream();
}
- Scanner scanner = manager.getContext().createScanner(table,
Authorizations.EMPTY);
- scanner.fetchColumnFamily(CurrentLocationColumnFamily.NAME);
- scanner.fetchColumnFamily(FutureLocationColumnFamily.NAME);
- scanner.setRange(new Range(row));
- for (Entry<Key,Value> entry : scanner) {
+
+ entries.forEach(entry -> {
if
(entry.getKey().getColumnFamily().equals(CurrentLocationColumnFamily.NAME)) {
assigned.put(entry.getKey(), entry.getValue());
} else if
(entry.getKey().getColumnFamily().equals(FutureLocationColumnFamily.NAME)) {
future.put(entry.getKey(), entry.getValue());
}
- }
- if (!future.isEmpty() && !assigned.isEmpty()) {
- Manager.log.warn("Found a tablet assigned and hosted, attempting to
repair");
- } else if (future.size() > 1 && assigned.isEmpty()) {
- Manager.log.warn("Found a tablet assigned to multiple servers,
attempting to repair");
- } else if (future.isEmpty() && assigned.size() > 1) {
- Manager.log.warn("Found a tablet hosted on multiple servers,
attempting to repair");
+ });
+
+ var count = future.size() + assigned.size();
+ if (count <= 1) {
+ Manager.log.trace("Tablet {} seems to have correct location based on
inspection",
+ tabletMetadata.getExtent());
} else {
- Manager.log.info("Attempted a repair, but nothing seems to be
obviously wrong. {} {}",
- assigned, future);
- return;
- }
- Iterator<Entry<Key,Value>> iter =
- Iterators.concat(future.entrySet().iterator(),
assigned.entrySet().iterator());
- while (iter.hasNext()) {
- Entry<Key,Value> entry = iter.next();
- TServerInstance alive =
manager.tserverSet.find(entry.getValue().toString());
- if (alive == null) {
- Manager.log.info("Removing entry {}", entry);
- BatchWriter bw = manager.getContext().createBatchWriter(table);
- Mutation m = new Mutation(entry.getKey().getRow());
- m.putDelete(entry.getKey().getColumnFamily(),
entry.getKey().getColumnQualifier());
- bw.addMutation(m);
- bw.close();
- return;
+ for (Map.Entry<Key,Value> entry : future.entrySet()) {
+ TServerInstance alive =
manager.tserverSet.find(entry.getValue().toString());
+ Manager.log.debug("Saw duplicate future location key:{} value:{}
alive:{} ",
+ entry.getKey(), entry.getValue(), alive != null);
+ }
+ for (Map.Entry<Key,Value> entry : assigned.entrySet()) {
+ TServerInstance alive =
manager.tserverSet.find(entry.getValue().toString());
+ Manager.log.debug("Saw duplicate current location key:{} value:{}
alive:{} ",
+ entry.getKey(), entry.getValue(), alive != null);
}
Review Comment:
Looked into doing this and realized the column family in the key will
indicate the type, so the two maps were redundant. Collapsed it to a single
map
[e0e2e92](https://github.com/apache/accumulo/pull/4668/commits/e0e2e929f95ab95d1f4dd2659dc2822edb9bcd7d)
--
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]