Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeMap;
Expand Down Expand Up @@ -82,7 +83,7 @@ public Repo<Manager> call(FateId fateId, Manager manager) throws Exception {
}
}

Preconditions.checkState(tabletMetadata.getOperationId().equals(opid),
Preconditions.checkState(opid.equals(tabletMetadata.getOperationId()),
"Tablet %s does not have expected operation id %s it has %s", splitInfo.getOriginal(), opid,
tabletMetadata.getOperationId());

Expand All @@ -94,6 +95,13 @@ public Repo<Manager> call(FateId fateId, Manager manager) throws Exception {
"Tablet unexpectedly had walogs %s %s %s", fateId, tabletMetadata.getLogs(),
tabletMetadata.getExtent());

Preconditions.checkState(!tabletMetadata.hasMerged(),
"Tablet unexpectedly has a merged marker %s %s", fateId, tabletMetadata.getExtent());

Preconditions.checkState(tabletMetadata.getCloned() == null,
"Tablet unexpectedly has a cloned marker %s %s %s", fateId, tabletMetadata.getCloned(),
tabletMetadata.getExtent());

var newTablets = splitInfo.getTablets();

var newTabletsFiles = getNewTabletFiles(newTablets, tabletMetadata,
Expand All @@ -120,7 +128,7 @@ static Map<KeyExtent,Map<StoredTabletFile,DataFileValue>> getNewTabletFiles(

newTablets.forEach(extent -> tabletsFiles.put(extent, new HashMap<>()));

// determine while files overlap which tablets and their estimated sizes
// determine which files overlap which tablets and their estimated sizes
tabletMetadata.getFilesMap().forEach((file, dataFileValue) -> {
FileUtil.FileInfo fileInfo = fileInfoProvider.apply(file);

Expand Down Expand Up @@ -187,6 +195,7 @@ private void addNewTablets(FateId fateId, Manager manager, TabletMetadata tablet
mutator.putTime(tabletMetadata.getTime());
tabletMetadata.getFlushId().ifPresent(mutator::putFlushId);
mutator.putPrevEndRow(newExtent.prevEndRow());

tabletMetadata.getCompacted().forEach(mutator::putCompacted);

tabletMetadata.getCompacted().forEach(compactedFateId -> log
Expand All @@ -195,7 +204,6 @@ private void addNewTablets(FateId fateId, Manager manager, TabletMetadata tablet
mutator.putTabletAvailability(tabletMetadata.getTabletAvailability());

tabletMetadata.getLoaded().forEach((k, v) -> mutator.putBulkFile(k.getTabletFile(), v));
tabletMetadata.getLogs().forEach(mutator::putWal);

newTabletsFiles.get(newExtent).forEach(mutator::putFile);

Expand All @@ -221,6 +229,9 @@ private void updateExistingTablet(FateId fateId, Manager manager, TabletMetadata
var mutator = tabletsMutator.mutateTablet(splitInfo.getOriginal()).requireOperation(opid)
.requireAbsentLocation().requireAbsentLogs();

Preconditions
.checkArgument(Objects.equals(tabletMetadata.getExtent().endRow(), newExtent.endRow()));

mutator.putPrevEndRow(newExtent.prevEndRow());

newTabletsFiles.get(newExtent).forEach(mutator::putFile);
Expand All @@ -246,6 +257,31 @@ private void updateExistingTablet(FateId fateId, Manager manager, TabletMetadata
tabletMetadata.getSelectedFiles().getFateId());
}

// Remove any user compaction requested markers as the tablet may fall outside the compaction
// range. The markers will be recreated if needed.
tabletMetadata.getUserCompactionsRequested().forEach(mutator::deleteUserCompactionRequested);

// scan entries are related to a hosted tablet, this tablet is not hosted so can safely delete
// these
tabletMetadata.getScans().forEach(mutator::deleteScan);

if (tabletMetadata.getHostingRequested()) {
// The range of the tablet is changing, so lets delete the hosting requested column in case
// this tablet does not actually need to be hosted.
mutator.deleteHostingRequested();
}

if (tabletMetadata.getSuspend() != null) {
// This no longer the exact tablet that was suspended. For consistency should either delete
// the suspension marker OR add it to the new tablets. Choosing to delete it.
mutator.deleteSuspension();
}

if (tabletMetadata.getLast() != null) {
// This is no longer the same tablet so lets delete the last location.
mutator.deleteLocation(tabletMetadata.getLast());
}

mutator.submit(tm -> false);

var result = tabletsMutator.process().get(splitInfo.getOriginal());
Expand Down
Loading