Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
keith-turner committed Jul 19, 2023
1 parent 6dc1549 commit d4da236
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public TabletFiles(String dirName, List<LogEntry> logEntries,
}
}

// ELASTICITY_TODO this method is no longer called because volume replacement needs to move from the tablet server to the manager. See #3625
/**
* This method does two things. First, it switches any volumes a tablet is using that are
* configured in instance.volumes.replacements. Second, if a tablet dir is no longer configured
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,28 +232,15 @@ public Tablet(final TabletServer tabletServer, final KeyExtent extent,
this.tabletTime = TabletTime.getInstance(metadata.getTime());
this.logId = tabletServer.createLogId();

// ELASTICITY_TODO do volume replacement elsewhere, tablet constructor does not seem like best
// place. Needs to use conditional mutation. Needs to work external compactions and scan
// servers, not sure it will work with scan servers and on demand. Maybe done in manager as a
// one time task.
/*
* // translate any volume changes TabletFiles tabletPaths = new
* TabletFiles(metadata.getDirName(), metadata.getLogs(), metadata.getFilesMap());
*
* VolumeUtil.updateTabletVolumes(tabletServer.getContext(), tabletServer.getLock(), extent,
* tabletPaths);
*
* final List<LogEntry> logEntries = tabletPaths.logEntries; final
* SortedMap<StoredTabletFile,DataFileValue> datafiles = tabletPaths.datafiles;
*/

constraintChecker = tableConfiguration.newDeriver(ConstraintChecker::new);

tabletMemory = new TabletMemory(this);

var logEntries = new ArrayList<>(metadata.getLogs());

// don't bother examining WALs for recovery if Table is being deleted
if (!metadata.getLogs().isEmpty() && !isBeingDeleted()) {
TabletLogger.recovering(extent, metadata.getLogs());
if (!logEntries.isEmpty() && !isBeingDeleted()) {
TabletLogger.recovering(extent, logEntries);
final AtomicLong entriesUsedOnTablet = new AtomicLong(0);
// track max time from walog entries without timestamps
final AtomicLong maxTime = new AtomicLong(Long.MIN_VALUE);
Expand All @@ -264,7 +251,7 @@ public Tablet(final TabletServer tabletServer, final KeyExtent extent,
absPaths.add(ref.getNormalizedPathStr());
}

tabletServer.recover(this.getTabletServer().getVolumeManager(), extent, metadata.getLogs(),
tabletServer.recover(this.getTabletServer().getVolumeManager(), extent, logEntries,
absPaths, m -> {
Collection<ColumnUpdate> muts = m.getUpdates();
for (ColumnUpdate columnUpdate : muts) {
Expand All @@ -287,7 +274,10 @@ public Tablet(final TabletServer tabletServer, final KeyExtent extent,
log.debug("No replayed mutations applied, removing unused entries for {}", extent);
// ELASTICITY_TODO use conditional mutation for update
MetadataTableUtil.removeUnusedWALEntries(getTabletServer().getContext(), extent,
metadata.getLogs(), tabletServer.getLock());
logEntries, tabletServer.getLock());
// intentionally not rereading metadata here because walogs are only used in the
// constructor
logEntries.clear();
}

} catch (Exception t) {
Expand All @@ -300,15 +290,14 @@ public Tablet(final TabletServer tabletServer, final KeyExtent extent,
}
// make some closed references that represent the recovered logs
currentLogs = new HashSet<>();
for (LogEntry logEntry : metadata.getLogs()) {
// TODO What is going on here? investigate.
for (LogEntry logEntry : logEntries) {
currentLogs.add(new DfsLogger(tabletServer.getContext(), tabletServer.getServerConfig(),
logEntry.filename, logEntry.getColumnQualifier().toString()));
}

rebuildReferencedLogs();

TabletLogger.recovered(extent, metadata.getLogs(), entriesUsedOnTablet.get(),
TabletLogger.recovered(extent, logEntries, entriesUsedOnTablet.get(),
getTabletMemory().getNumEntries());
}

Expand All @@ -318,7 +307,6 @@ public Tablet(final TabletServer tabletServer, final KeyExtent extent,

computeNumEntries();

// TODO does this still make sense??
getScanfileManager().removeFilesAfterScan(metadata.getScans());
}

Expand Down Expand Up @@ -1259,19 +1247,20 @@ public Optional<StoredTabletFile> updateTabletDataFile(long maxCommittedTime,
ReferencedTabletFile newDatafile, DataFileValue dfv, Set<String> unusedWalLogs,
long flushId) {

// expect time to only move forward from what was recently seen in metadata table
Preconditions.checkArgument(maxCommittedTime >= getMetadata().getTime().getTime());
// expect time to only move forward from what was recently seen in metadata table
Preconditions.checkArgument(maxCommittedTime >= getMetadata().getTime().getTime());

// ELASTICITY_TODO use conditional mutation, can check time and location
// ELASTICITY_TODO use conditional mutation, can check time and location

// ELASTICITY_TODO minor compaction will need something like the bulk import loaded column
// to avoid : partial write, compact of file in partial write, and then another write of the file
// to avoid : partial write, compact of file in partial write, and then another write of the
// file
// leading to the file being added twice.

return ManagerMetadataUtil.updateTabletDataFile(getTabletServer().getContext(), extent,
newDatafile, dfv, tabletTime.getMetadataTime(maxCommittedTime),
tabletServer.getClientAddressString(), tabletServer.getLock(), unusedWalLogs,
lastLocation, flushId);
return ManagerMetadataUtil.updateTabletDataFile(getTabletServer().getContext(), extent,
newDatafile, dfv, tabletTime.getMetadataTime(maxCommittedTime),
tabletServer.getClientAddressString(), tabletServer.getLock(), unusedWalLogs, lastLocation,
flushId);
}

@Override
Expand Down

0 comments on commit d4da236

Please sign in to comment.