[CORE-15307] better prefix truncation checks#29274
Conversation
Add a new virtual method to check if a sink partition supports prefix truncation before attempting the operation. The real implementation checks if the partition is locally collectable. Signed-off-by: Michael Boquard <michael@redpanda.com>
…itions Check can_prefix_truncate() before attempting to synchronize start offsets. This avoids unnecessary work for partitions that don't support prefix truncation. Signed-off-by: Michael Boquard <michael@redpanda.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a capability check to prevent cluster link replication from attempting prefix truncation on partitions that don't support it, such as cloud topics. The check interrogates the partition's configuration to determine local collectability before proceeding with truncation operations.
Changes:
- Added
can_prefix_truncate()method to thedata_sinkinterface to check if prefix truncation is supported - Updated
maybe_synchronize_start_offset()to early-return when prefix truncation is not supported - Implemented the new method across all sink implementations (production and test code)
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/v/cluster_link/replication/deps.h | Adds interface method declaration for prefix truncation capability check |
| src/v/cluster_link/replication/partition_replicator.cc | Adds early-return logic when sink doesn't support prefix truncation |
| src/v/cluster_link/service.cc | Implements capability check based on partition's local collectability |
| src/v/cluster_link/replication/tests/partition_replicator_tests.cc | Implements capability check in test sink (returns true) |
| src/v/cluster_link/replication/tests/link_replication_mgr_tests.cc | Implements capability check in test sink (returns true) |
| src/v/cluster_link/replication/tests/deps_test_impl.h | Adds method declaration to test accounting sink |
| src/v/cluster_link/replication/tests/deps_test_impl.cc | Implements capability check in test accounting sink (returns true) |
| // Returns the HWM of the partition | ||
| virtual kafka::offset high_watermark() const = 0; | ||
|
|
||
| // Returns whether or not the sink support prefix truncation |
There was a problem hiding this comment.
Corrected grammar: 'support' should be 'supports' to match subject-verb agreement.
| // Returns whether or not the sink support prefix truncation | |
| // Returns whether or not the sink supports prefix truncation |
|
|
||
| bool can_prefix_truncate() const final { | ||
| _gate.check(); | ||
| return _partition->get_ntp_config().is_locally_collectable(); |
There was a problem hiding this comment.
We need to check this because source and shadow topics can have mismatched retention configurations?
There was a problem hiding this comment.
No - cleanup.policy is always replicated, however is_locally_collectable also checks to see if TS is enabled on the topic which could differ between source and shadow.
|
/backport v25.3.x |
Add a capability check to the sink partition interface to determine whether prefix truncation is supported before attempting the operation. This prevents unnecessary work for partitions that don't support prefix truncation, such as cloud topics.
Fixes: CORE-15307
Summary
When cluster link replication attempts to synchronize start offsets between source and sink partitions, it currently proceeds with prefix truncation logic regardless of whether the sink partition actually supports this operation. Cloud topics, for example, do not support local prefix truncation as they manage retention differently.
This PR:
can_prefix_truncate()method to the sink partition interface that checks if the partition is locally collectablemaybe_synchronize_start_offset()to early-return when prefix truncation is not supported, avoiding unnecessary computationBackports Required
Release Notes
Bug Fixes