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
60
61
62
63
64
//! Static configuration for the native `LockService`: the entity message name,
//! the versioned outbox topics, the durable status tokens, the TTL/quota bounds,
//! and the expiry-reaper cadence knobs. Extracted verbatim from the former god
//! file; every value is byte-stable for downstream audit/CDC consumers.
/// Default page size for `ListLocks` when the caller does not specify one.
pub const DEFAULT_LOCK_LIST_LIMIT: i32 = 100;
pub const LOCK_MSG: &str = "udb.core.lock.entity.v1.Lock";
pub const TOPIC_ACQUIRED: &str = "udb.lock.lock.acquired.v1";
pub const TOPIC_RENEWED: &str = "udb.lock.lock.renewed.v1";
pub const TOPIC_RELEASED: &str = "udb.lock.lock.released.v1";
/// Emitted by the leader-elected expiry reaper when a lapsed HELD row is flipped
/// to EXPIRED (16.5.1).
pub const TOPIC_EXPIRED: &str = "udb.lock.lock.expired.v1";
pub const STATUS_HELD: &str = "HELD";
pub const STATUS_RELEASED: &str = "RELEASED";
/// Terminal state stamped by the expiry reaper on a HELD row whose lease lapsed
/// without a release. The `status` column is a VARCHAR(20); the entity-proto
/// comment currently enumerates only `HELD | RELEASED` (out-of-fence follow-up).
pub const STATUS_EXPIRED: &str = "EXPIRED";
/// Default lease TTL when the caller does not specify one.
pub const DEFAULT_LEASE_TTL_SECONDS: i64 = 30;
/// Upper bound on a lease TTL so a caller cannot pin a lock indefinitely.
pub const MAX_LEASE_TTL_SECONDS: i64 = 3600;
/// Per-tenant active-lock budget. Bounds the durable lock table so one tenant
/// cannot exhaust the shared store; a new acquire beyond this fails closed.
pub const MAX_ACTIVE_LOCKS_PER_TENANT: usize = 256;
/// Upper bound on rows one expiry-reaper pass claims — bounds the sweep
/// transaction the same way `SCHEDULER_TICK_BATCH` bounds the scheduler tick.
/// `pub(crate)` so the leader spawn site passes the named const (16.11.3).
pub const LOCK_EXPIRY_SWEEP_BATCH: i64 = 200;
/// Default reaper cadence; overridable via [`LOCK_EXPIRY_INTERVAL_ENV`].
const DEFAULT_LOCK_EXPIRY_INTERVAL_SECS: u64 = 30;
const LOCK_EXPIRY_INTERVAL_ENV: &str = "UDB_LOCK_EXPIRY_INTERVAL_SECS";
/// Reaper cadence for the leader spawn site — env resolved once at spawn,
/// mirroring `cache_service::cache_invalidation_interval`.
pub
/// Clamp a requested TTL into `[DEFAULT, MAX]`; non-positive → default.
pub