Skip to content

Commit

Permalink
STAR-1065: add commit log position to truncation notification (apache…
Browse files Browse the repository at this point in the history
…#322)

(cherry picked from commit 5f2c6ef)
  • Loading branch information
jakubzytka authored and jacek-lewandowski committed Mar 7, 2022
1 parent c6e4fa2 commit 20b1bd8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/java/org/apache/cassandra/db/ColumnFamilyStore.java
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions src/java/org/apache/cassandra/db/lifecycle/Tracker.java
Expand Up @@ -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);
}
Expand Down
Expand Up @@ -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;
}
}

0 comments on commit 20b1bd8

Please sign in to comment.