maedhroz commented on a change in pull request #1417:
URL: https://github.com/apache/cassandra/pull/1417#discussion_r794016568
##########
File path: test/unit/org/apache/cassandra/db/lifecycle/LogTransactionTest.java
##########
@@ -222,6 +224,37 @@ public void testUntrack() throws Throwable
assertFiles(dataFolder.getPath(), Collections.<String>emptySet());
}
+ @Test
+ public void testUntrackIdenticalLogFilesOnDisk() throws Throwable
+ {
+ ColumnFamilyStore cfs = MockSchema.newCFS(KEYSPACE);
+ File datadir1 = Files.createTempDirectory("datadir1").toFile();
+ File datadir2 = Files.createTempDirectory("datadir2").toFile();
+ SSTableReader sstable1 = sstable(datadir1, cfs, 1, 128);
+ SSTableReader sstable2 = sstable(datadir2, cfs, 1, 128);
+
+
+ for (Consumer<LogTransaction> c :
Arrays.<Consumer<LogTransaction>>asList((log) -> log.trackNew(sstable2),
+
(log) -> log.obsoleted(sstable2),
+
(log) -> log.txnFile().addAll(LogRecord.Type.ADD,
Collections.singleton(sstable2))))
+ {
+ try (LogTransaction log = new
LogTransaction(OperationType.COMPACTION))
+ {
+ log.trackNew(sstable1); // creates a log file in datadir1
+ log.untrackNew(sstable1); // removes sstable1 from `records`,
but still on disk & in `onDiskRecords`
+
+ c.accept(log); // creates a log file in datadir2, based on
contents in onDiskRecords
+ byte[] log1 =
Files.readAllBytes(log.logFiles().get(0).toPath());
+ byte[] log2 =
Files.readAllBytes(log.logFiles().get(1).toPath());
+ assertArrayEquals(log1, log2);
+ }
+ }
+ sstable1.selfRef().release();
+ sstable2.selfRef().release();
+ Thread.sleep(1);
Review comment:
nit: generally don't like sleeps, but I couldn't think of a better way
offhand
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]