clohfink commented on code in PR #3730:
URL: https://github.com/apache/cassandra/pull/3730#discussion_r1901381973


##########
src/java/org/apache/cassandra/db/ReadCommand.java:
##########
@@ -867,6 +868,130 @@ protected LongPredicate getPurgeEvaluator()
         return Transformation.apply(iterator, new 
WithoutPurgeableTombstones());
     }
 
+
+    /**
+     * Wraps the provided iterator so that metrics on count of purgeable 
tombstones are tracked and traced.
+     * It tracks only tombstones with localDeletionTime < now - 
gc_grace_period.
+     * Other (non-purgeable) tombstones will be tracked by regular Cassandra 
logic later.
+     */
+    private UnfilteredPartitionIterator 
withPurgeableTombstonesMetricRecording(UnfilteredPartitionIterator iter,
+                                                                               
ColumnFamilyStore cfs)
+    {
+        class PurgeableTombstonesMetricRecording extends 
Transformation<UnfilteredRowIterator>
+        {
+            private int purgeableTombstones = 0;
+
+            @Override
+            public UnfilteredRowIterator 
applyToPartition(UnfilteredRowIterator iter)
+            {
+                return Transformation.apply(iter, this);

Review Comment:
   with 
   ```java
               public UnfilteredRowIterator 
applyToPartition(UnfilteredRowIterator iter)
               {
                   if (!iter.partitionLevelDeletion().isLive())
                       purgeableTombstones++;
   ```
   above passes
   



##########
src/java/org/apache/cassandra/metrics/TableMetrics.java:
##########
@@ -771,6 +773,7 @@ public Long getValue()
         additionalWriteLatencyNanos = 
createTableGauge("AdditionalWriteLatencyNanos", () -> 
MICROSECONDS.toNanos(cfs.additionalWriteLatencyMicros));
 
         tombstoneScannedHistogram = 
createTableHistogram("TombstoneScannedHistogram", 
cfs.keyspace.metric.tombstoneScannedHistogram, false);
+        purgeableTombstoneScannedHistogram = 
createTableHistogram("PurgeableTombstoneScannedHistogram", 
cfs.keyspace.metric.purgeableTombstoneScannedHistogram, false);

Review Comment:
   considerZeros should be true



##########
src/java/org/apache/cassandra/db/ReadCommand.java:
##########
@@ -867,6 +868,130 @@ protected LongPredicate getPurgeEvaluator()
         return Transformation.apply(iterator, new 
WithoutPurgeableTombstones());
     }
 
+
+    /**
+     * Wraps the provided iterator so that metrics on count of purgeable 
tombstones are tracked and traced.
+     * It tracks only tombstones with localDeletionTime < now - 
gc_grace_period.
+     * Other (non-purgeable) tombstones will be tracked by regular Cassandra 
logic later.
+     */
+    private UnfilteredPartitionIterator 
withPurgeableTombstonesMetricRecording(UnfilteredPartitionIterator iter,
+                                                                               
ColumnFamilyStore cfs)
+    {
+        class PurgeableTombstonesMetricRecording extends 
Transformation<UnfilteredRowIterator>
+        {
+            private int purgeableTombstones = 0;
+
+            @Override
+            public UnfilteredRowIterator 
applyToPartition(UnfilteredRowIterator iter)
+            {
+                return Transformation.apply(iter, this);

Review Comment:
   ```java
   public class TestTest extends CQLTester
   {
       @BeforeClass
       public static void setUpClass()
       {
           CQLTester.setUpClass();
       }
       @Test
       public void test() throws Throwable
       {
           String table = createTable("CREATE TABLE %s (a int, b text, PRIMARY 
KEY (a)) WITH gc_grace_seconds = 0");
           execute("DELETE FROM %s WHERE a = 1");
           Util.flushTable(KEYSPACE, table);
           Thread.sleep(1000);
           Assert.assertEquals(0, ColumnFamilyStore.getIfExists(KEYSPACE, 
table).metric.purgeableTombstoneScannedHistogram.getCount());
           execute("SELECT * FROM %s");
           Assert.assertEquals(1, ColumnFamilyStore.getIfExists(KEYSPACE, 
table).metric.purgeableTombstoneScannedHistogram.getCount());
           Assert.assertEquals(1, ColumnFamilyStore.getIfExists(KEYSPACE, 
table).metric.purgeableTombstoneScannedHistogram.getSnapshot().getMax());
       }
   }
   ```
   fails for example when considerZeroes is true



-- 
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: pr-unsubscr...@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org
For additional commands, e-mail: pr-h...@cassandra.apache.org

Reply via email to