keith-turner commented on code in PR #3957:
URL: https://github.com/apache/accumulo/pull/3957#discussion_r1398255712
##########
server/manager/src/main/java/org/apache/accumulo/manager/TabletGroupWatcher.java:
##########
@@ -954,28 +992,55 @@ 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);
+ KeyExtent stop = highTablet.getExtent();
+ Manager.log.debug("Highest tablet is {}", stop);
- 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();
+ 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)) {
deleteTablets(info, scanRange, bw, client);
+ // Clear the merged marker after we finish deleting tablets
+ clearMerged(info);
Review Comment:
Could pass the batchwriter and/or highTablet. Also could flush the
batchwriter.
```suggestion
try (BatchWriter bw = client.createBatchWriter(targetSystemTable)) {
deleteTablets(info, highTablet, scanRange, bw, client);
// flush any changes before removing merge marker, after merge marker
is removed may not run again
bw.flush();
// Clear the merged marker after we finish deleting tablets
clearMerged(info, bw, highTablet);
```
##########
server/manager/src/main/java/org/apache/accumulo/manager/TabletGroupWatcher.java:
##########
@@ -859,19 +857,14 @@ private void mergeMetadataRecords(MergeInfo info) throws
AccumuloException {
KeyExtent previousKeyExtent = null;
KeyExtent lastExtent = null;
- try (BatchWriter bw = client.createBatchWriter(targetSystemTable)) {
- // Check if we have already previously fenced the tablets
- if (highTablet.isMerged()) {
- Manager.log.debug("tablet metadata already fenced for merge");
- if (!highTablet.hasPrevRowColumn()) {
- Manager.log.debug("tablet already merged, returning");
- return;
- }
- // Continue and delete tablets as we already finished fencing
- deleteTablets(info, scanRange, bw, client);
- return;
- }
+ // Check if we have already previously fenced the tablets
+ if (highTablet.isMerged()) {
+ Manager.log.debug("tablet metadata already fenced for merge");
Review Comment:
Would be good to include some info in the log message that identifies
specific merge operation
##########
server/manager/src/main/java/org/apache/accumulo/manager/TabletGroupWatcher.java:
##########
@@ -954,28 +992,55 @@ 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);
Review Comment:
May be able to just return if the merged marker is not present, would
indicate running a 2nd time. But if runnning the code again in this case is
not harmful that may not matter.
--
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]