keith-turner commented on code in PR #3957:
URL: https://github.com/apache/accumulo/pull/3957#discussion_r1398263825
##########
server/manager/src/main/java/org/apache/accumulo/manager/TabletGroupWatcher.java:
##########
@@ -954,28 +987,62 @@ private void mergeMetadataRecords(MergeInfo info) throws
AccumuloException {
// delete any entries for external compactions
extCompIds.forEach(ecid ->
m.putDelete(ExternalCompactionColumnFamily.STR_NAME, ecid));
- if (!m.getUpdates().isEmpty()) {
- bw.addMutation(m);
- }
+ // Add a marker so we know the tablets have been fenced in case the
merge operation
+ // needs to be recovered and restarted to finish later.
+ MergedColumnFamily.MERGED_COLUMN.put(m, MergedColumnFamily.MERGED_VALUE);
+ // Add the prev row column update to the same mutation as the
+ // file updates so it will be atomic and only update the prev row
+ // if the tablets were fenced
+ Preconditions.checkState(firstPrevRowValue != null,
+ "Previous row entry for lowest tablet was not found.");
+ stop = new KeyExtent(stop.tableId(), stop.endRow(),
+ TabletColumnFamily.decodePrevEndRow(firstPrevRowValue));
+ TabletColumnFamily.PREV_ROW_COLUMN.put(m,
+ TabletColumnFamily.encodePrevEndRow(stop.prevEndRow()));
+ Manager.log.debug("Setting the prevRow for last tablet: {}", stop);
+ bw.addMutation(m);
bw.flush();
Manager.log.debug("Moved {} files to {}", fileCount, stop);
+ } catch (Exception ex) {
+ throw new AccumuloException(ex);
+ }
+ }
- if (firstPrevRowValue == null) {
- Manager.log.debug("tablet already merged");
- return;
- }
+ private void deleteMergedTablets(MergeInfo info) throws AccumuloException {
+ KeyExtent range = info.getExtent();
+ Manager.log.debug("Deleting merged tablets for {}", range);
+ HighTablet highTablet = getHighTablet(range);
+ if (!highTablet.isMerged()) {
+ Manager.log.debug("Tablets have already been deleted for merge with
range {}, returning",
+ range);
+ return;
+ }
- stop = new KeyExtent(stop.tableId(), stop.endRow(),
- TabletColumnFamily.decodePrevEndRow(firstPrevRowValue));
- Mutation updatePrevRow = TabletColumnFamily.createPrevRowMutation(stop);
- Manager.log.debug("Setting the prevRow for last tablet: {}", stop);
- bw.addMutation(updatePrevRow);
- bw.flush();
+ KeyExtent stop = highTablet.getExtent();
+ Manager.log.debug("Highest tablet is {}", stop);
+
+ Text stopRow = stop.toMetaRow();
+ Text start = range.prevEndRow();
+ if (start == null) {
+ start = new Text();
+ }
+ Range scanRange =
+ new Range(TabletsSection.encodeRow(range.tableId(), start), false,
stopRow, false);
+ String targetSystemTable = MetadataTable.NAME;
+ if (range.isMeta()) {
+ targetSystemTable = RootTable.NAME;
+ }
+
+ AccumuloClient client = manager.getContext();
+ try (BatchWriter bw = client.createBatchWriter(targetSystemTable)) {
+ // Continue and delete the tablets that were merged
deleteTablets(info, scanRange, bw, client);
+ // Clear the merged marker after we finish deleting tablets
+ clearMerged(info, bw);
Review Comment:
Could pass highTablet to these two functions as they reread it.
--
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]