diff --git a/core/src/main/java/org/apache/accumulo/core/metadata/schema/MetadataTime.java b/core/src/main/java/org/apache/accumulo/core/metadata/schema/MetadataTime.java index eb96c309b98..eb79b6d017b 100644 --- a/core/src/main/java/org/apache/accumulo/core/metadata/schema/MetadataTime.java +++ b/core/src/main/java/org/apache/accumulo/core/metadata/schema/MetadataTime.java @@ -121,4 +121,9 @@ public int compareTo(MetadataTime mtime) { "Cannot compare different time types: " + this + " and " + mtime); } } + + @Override + public String toString() { + return encode(); + } } diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java index f08922fa8c8..5fda28f1fe4 100644 --- a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java +++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java @@ -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; @@ -1297,8 +1297,8 @@ TabletServer getTabletServer() { * Update tablet file data from flush. Returns a StoredTabletFile if there are data entries. */ public Optional updateTabletDataFile(long maxCommittedTime, - ReferencedTabletFile newDatafile, DataFileValue dfv, Set unusedWalLogs, - long flushId) { + ReferencedTabletFile newDatafile, DataFileValue dfv, Set unusedWalLogs, long flushId, + MinorCompactionReason mincReason) { Preconditions.checkState(refreshLock.isHeldByCurrentThread()); @@ -1321,8 +1321,12 @@ public Optional 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 newFile = Optional.empty(); @@ -1350,11 +1354,14 @@ public Optional 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; @@ -1426,7 +1433,7 @@ public boolean isOnDemand() { void bringMinorCompactionOnline(ReferencedTabletFile tmpDatafile, ReferencedTabletFile newDatafile, DataFileValue dfv, CommitSession commitSession, - long flushId) { + long flushId, MinorCompactionReason mincReason) { Optional newFile; // rename before putting in metadata table, so files in metadata table should // always exist @@ -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 { @@ -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()); diff --git a/test/src/main/java/org/apache/accumulo/test/functional/RestartIT.java b/test/src/main/java/org/apache/accumulo/test/functional/RestartIT.java index adbd878e6a4..3ab2b968593 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/RestartIT.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/RestartIT.java @@ -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]; @@ -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]; @@ -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);