Skip to content

Commit

Permalink
Merge branch 'elasticity' into 3632-move-replacements-to-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
dlmarion committed Oct 26, 2023
2 parents 596538c + c44216d commit b4a7167
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,9 @@ public int compareTo(MetadataTime mtime) {
"Cannot compare different time types: " + this + " and " + mtime);
}
}

@Override
public String toString() {
return encode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ DataFileValue minorCompact(InMemoryMap memTable, ReferencedTabletFile tmpDatafil
try (Scope scope = span2.makeCurrent()) {
bringMinorCompactionOnline(tmpDatafile, newDatafile,
new DataFileValue(stats.getFileSize(), stats.getEntriesWritten()), commitSession,
flushId);
flushId, mincReason);
} catch (Exception e) {
TraceUtil.setException(span2, e, true);
throw e;
Expand Down Expand Up @@ -1297,8 +1297,8 @@ TabletServer getTabletServer() {
* Update tablet file data from flush. Returns a StoredTabletFile if there are data entries.
*/
public Optional<StoredTabletFile> updateTabletDataFile(long maxCommittedTime,
ReferencedTabletFile newDatafile, DataFileValue dfv, Set<String> unusedWalLogs,
long flushId) {
ReferencedTabletFile newDatafile, DataFileValue dfv, Set<String> unusedWalLogs, long flushId,
MinorCompactionReason mincReason) {

Preconditions.checkState(refreshLock.isHeldByCurrentThread());

Expand All @@ -1321,8 +1321,12 @@ public Optional<StoredTabletFile> updateTabletDataFile(long maxCommittedTime,
}

try (var tabletsMutator = getContext().getAmple().conditionallyMutateTablets()) {
var tablet = tabletsMutator.mutateTablet(extent)
.requireLocation(Location.current(tabletServer.getTabletSession()))

var expectedLocation = mincReason == MinorCompactionReason.RECOVERY
? Location.future(tabletServer.getTabletSession())
: Location.current(tabletServer.getTabletSession());

var tablet = tabletsMutator.mutateTablet(extent).requireLocation(expectedLocation)
.requireSame(lastTabletMetadata, ColumnType.TIME);

Optional<StoredTabletFile> newFile = Optional.empty();
Expand Down Expand Up @@ -1350,11 +1354,14 @@ public Optional<StoredTabletFile> updateTabletDataFile(long maxCommittedTime,
// between the write and check. Second, some flushes do not produce a file.
tablet.submit(tabletMetadata -> tabletMetadata.getTime().equals(newTime));

if (tabletsMutator.process().get(extent).getStatus()
!= Ample.ConditionalResult.Status.ACCEPTED) {
var result = tabletsMutator.process().get(extent);
if (result.getStatus() != Ample.ConditionalResult.Status.ACCEPTED) {

log.error("Metadata for failed tablet file update : {}", result.readMetadata());

// Include the things that could have caused the write to fail.
throw new IllegalStateException("Unable to write minor compaction. " + extent + " "
+ tabletServer.getTabletSession() + " " + expectedTime);
+ expectedLocation + " " + expectedTime);
}

return newFile;
Expand Down Expand Up @@ -1426,7 +1433,7 @@ public boolean isOnDemand() {

void bringMinorCompactionOnline(ReferencedTabletFile tmpDatafile,
ReferencedTabletFile newDatafile, DataFileValue dfv, CommitSession commitSession,
long flushId) {
long flushId, MinorCompactionReason mincReason) {
Optional<StoredTabletFile> newFile;
// rename before putting in metadata table, so files in metadata table should
// always exist
Expand Down Expand Up @@ -1481,7 +1488,7 @@ void bringMinorCompactionOnline(ReferencedTabletFile tmpDatafile,
// before the following metadata write is made

newFile = updateTabletDataFile(commitSession.getMaxCommittedTime(), newDatafile, dfv,
unusedWalLogs, flushId);
unusedWalLogs, flushId, mincReason);

finishClearingUnusedLogs();
} finally {
Expand Down Expand Up @@ -1532,7 +1539,7 @@ public void refreshMetadata(RefreshPurpose refreshPurpose) {

Preconditions.checkState(tabletMetadata != null, "Tablet no longer exits %s", getExtent());
Preconditions.checkState(
Location.current(tabletServer.getTabletSession()).equals(tabletMetadata.getLocation()),
tabletServer.getTabletSession().equals(tabletMetadata.getLocation().getServerInstance()),
"Tablet %s location %s is not this tserver %s", getExtent(), tabletMetadata.getLocation(),
tabletServer.getTabletSession());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public void restartManager() throws Exception {
}

@Test
@Disabled // ELASTICITY_TODO
public void restartManagerRecovery() throws Exception {
try (AccumuloClient c = Accumulo.newClient().from(getClientProps()).build()) {
String tableName = getUniqueNames(1)[0];
Expand Down Expand Up @@ -203,7 +202,6 @@ public void restartManagerSplit() throws Exception {
}

@Test
@Disabled // ELASTICITY_TODO
public void killedTabletServer() throws Exception {
try (AccumuloClient c = Accumulo.newClient().from(getClientProps()).build()) {
String tableName = getUniqueNames(1)[0];
Expand All @@ -218,7 +216,6 @@ public void killedTabletServer() throws Exception {
}

@Test
@Disabled // ELASTICITY_TODO
public void killedTabletServer2() throws Exception {
try (AccumuloClient c = Accumulo.newClient().from(getClientProps()).build()) {
final String[] names = getUniqueNames(2);
Expand Down

0 comments on commit b4a7167

Please sign in to comment.