1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! Consumer watermark tracking for CDC retention coordination
//!
//! This module provides functionality to compute the minimum checkpoint version
//! across all CDC consumers. This watermark serves as a safety floor for retention
//! policies - versions at or above the watermark cannot be cleaned up because
//! consumers still need them.
use ;
/// Computes the consumer watermark by finding the minimum checkpoint version
/// across all registered CDC consumers.
///
/// The watermark represents the lowest commit version that any consumer has
/// checkpointed. Retention policies must not clean up versions at or above
/// this watermark, as consumers still need them.
///
/// # Consumer Discovery
///
/// Consumers are discovered by scanning checkpoint keys. A consumer exists
/// if and only if it has written a checkpoint. Consumers without checkpoints
/// are not considered.
///
/// # Return Value
///
/// Returns the minimum `CommitVersion` across all consumer checkpoints.
/// If no consumers exist (no checkpoints found), returns `CommitVersion(1)`
/// as a safe default (prevents cleanup of all versions).
///
/// # Example
///
/// ```ignore
/// let watermark = compute_watermark(&mut txn)?;
/// // Now retention can safely cleanup versions < watermark
/// ```