From f69b97ac815fcd96712bb5d1b464d12e736b1d8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BBytka?= Date: Tue, 1 Feb 2022 20:07:08 +0100 Subject: [PATCH] STAR-1065: add commit log position to truncation notification (#322) (cherry picked from commit 5f2c6efbf6b3e747ef9fa74ff05e95d36968ff89) --- src/java/org/apache/cassandra/db/ColumnFamilyStore.java | 2 +- src/java/org/apache/cassandra/db/lifecycle/Tracker.java | 4 ++-- .../cassandra/notifications/TruncationNotification.java | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java index 1529fd244c75..d796e12216dd 100644 --- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java +++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java @@ -2486,7 +2486,7 @@ public void run() // stream in data that is actually supposed to have been deleted ActiveRepairService.instance.abort((prs) -> prs.getTableIds().contains(metadata.id), "Stopping parent sessions {} due to truncation of tableId="+metadata.id); - data.notifyTruncated(truncatedAt); + data.notifyTruncated(replayAfter, truncatedAt); if (!noSnapshot && DatabaseDescriptor.isAutoSnapshot()) snapshot(Keyspace.getTimestampedSnapshotNameWithPrefix(name, SNAPSHOT_TRUNCATE_PREFIX)); diff --git a/src/java/org/apache/cassandra/db/lifecycle/Tracker.java b/src/java/org/apache/cassandra/db/lifecycle/Tracker.java index a98c85d7ba59..6637f33e251d 100644 --- a/src/java/org/apache/cassandra/db/lifecycle/Tracker.java +++ b/src/java/org/apache/cassandra/db/lifecycle/Tracker.java @@ -520,9 +520,9 @@ public void notifyDeleting(SSTableReader deleting) subscriber.handleNotification(notification, this); } - public void notifyTruncated(long truncatedAt) + public void notifyTruncated(CommitLogPosition replayAfter, long truncatedAt) { - INotification notification = new TruncationNotification(truncatedAt); + INotification notification = new TruncationNotification(replayAfter, truncatedAt); for (INotificationConsumer subscriber : subscribers) subscriber.handleNotification(notification, this); } diff --git a/src/java/org/apache/cassandra/notifications/TruncationNotification.java b/src/java/org/apache/cassandra/notifications/TruncationNotification.java index 345dd17e290c..271ae0d00bf5 100644 --- a/src/java/org/apache/cassandra/notifications/TruncationNotification.java +++ b/src/java/org/apache/cassandra/notifications/TruncationNotification.java @@ -17,16 +17,20 @@ */ package org.apache.cassandra.notifications; +import org.apache.cassandra.db.commitlog.CommitLogPosition; + /** * Fired during truncate, after the memtable has been flushed but before any * snapshot is taken and SSTables are discarded */ public class TruncationNotification implements INotification { + public final CommitLogPosition replayAfter; public final long truncatedAt; - public TruncationNotification(long truncatedAt) + public TruncationNotification(CommitLogPosition replayAfter, long truncatedAt) { + this.replayAfter = replayAfter; this.truncatedAt = truncatedAt; } }