@@ -26,22 +26,7 @@ pub enum CatalogRowKind {
2626 // 0x04 and 0x05 are reserved: they were the in-catalog free-list and
2727 // deferred-free queue, superseded by the durable free-list chain rooted in
2828 // the A/B header (see `crate::pager::freelist`). Do not reuse these bytes.
29- /// Durable reader pin. One row per active cross-process read transaction.
30- /// Key: `[0x06] || pid_u32_be[4] || lease_id_u64_be[8]` (13 bytes).
31- /// Value: `commit_id[8] || root_page_id[8] || catalog_root_page_id[8] ||
32- /// free_list_root_page_id[8] || expires_unix_seconds[8] || flags[1]`
33- /// (41 bytes).
34- ///
35- /// On `begin_read` the writer inserts a row; on `ReadTxn::drop` the row is
36- /// deleted. If a reader crashes, its row is cleaned up at the next
37- /// `Db::open` of a writer handle. A row whose `expires_unix_seconds` is
38- /// older than the current wall-clock time is treated as expired by GC and
39- /// does not block page reclamation.
40- ///
41- /// On a `ReadOnly` or `Follower` handle that cannot write to its own
42- /// catalog, reader pins are maintained in-memory only and the writer process
43- /// must be trusted to honor the catalog pins.
44- ReaderPin = 0x06 ,
29+ // 0x06 is reserved, deliberately uninterpreted, and must never be reused.
4530 /// Reserved (`0x07`). Older builds wrote an incremental-compaction watermark
4631 /// here; compaction is now a single atomic operation and never writes it.
4732 /// Retained as a row-kind boundary and so any legacy row is recognised and
@@ -112,20 +97,6 @@ pub struct RealmQuotas {
11297 pub max_segment_bytes : Option < u64 > ,
11398}
11499
115- /// Value for a durable reader-pin row.
116- #[ derive( Debug , Clone , PartialEq , Eq ) ]
117- pub struct ReaderPinValue {
118- pub commit_id : u64 ,
119- pub root_page_id : u64 ,
120- pub catalog_root_page_id : u64 ,
121- pub free_list_root_page_id : u64 ,
122- pub expires_unix_seconds : u64 ,
123- pub flags : u8 ,
124- }
125-
126- pub const READER_PIN_VALUE_LEN : usize = 41 ;
127- pub const READER_PIN_KEY_LEN : usize = 13 ;
128-
129100pub const SEGMENT_META_LEN : usize = 94 ;
130101pub const REALM_QUOTAS_LEN : usize = 33 ;
131102
@@ -191,63 +162,6 @@ impl Catalog {
191162 } )
192163 }
193164
194- /// Reader-pin row key: `[0x06] || pid_u32_be[4] || lease_id_u64_be[8]`.
195- #[ must_use]
196- pub fn reader_pin_key ( pid : u32 , lease_id : u64 ) -> [ u8 ; READER_PIN_KEY_LEN ] {
197- let mut k = [ 0u8 ; READER_PIN_KEY_LEN ] ;
198- k[ 0 ] = CatalogRowKind :: ReaderPin as u8 ;
199- k[ 1 ..5 ] . copy_from_slice ( & pid. to_be_bytes ( ) ) ;
200- k[ 5 ..13 ] . copy_from_slice ( & lease_id. to_be_bytes ( ) ) ;
201- k
202- }
203-
204- /// Range start key for all reader-pin rows: `[0x06]`.
205- #[ must_use]
206- pub fn reader_pin_range_start ( ) -> [ u8 ; 1 ] {
207- [ CatalogRowKind :: ReaderPin as u8 ]
208- }
209-
210- /// Range end key (exclusive) for all reader-pin rows: `[0x07]`.
211- #[ must_use]
212- pub fn reader_pin_range_end ( ) -> [ u8 ; 1 ] {
213- [ CatalogRowKind :: CompactionState as u8 ]
214- }
215-
216- /// Encode a `ReaderPinValue` as 41 bytes.
217- #[ must_use]
218- pub fn encode_reader_pin ( v : & ReaderPinValue ) -> [ u8 ; READER_PIN_VALUE_LEN ] {
219- let mut o = [ 0u8 ; READER_PIN_VALUE_LEN ] ;
220- o[ 0 ..8 ] . copy_from_slice ( & v. commit_id . to_le_bytes ( ) ) ;
221- o[ 8 ..16 ] . copy_from_slice ( & v. root_page_id . to_le_bytes ( ) ) ;
222- o[ 16 ..24 ] . copy_from_slice ( & v. catalog_root_page_id . to_le_bytes ( ) ) ;
223- o[ 24 ..32 ] . copy_from_slice ( & v. free_list_root_page_id . to_le_bytes ( ) ) ;
224- o[ 32 ..40 ] . copy_from_slice ( & v. expires_unix_seconds . to_le_bytes ( ) ) ;
225- o[ 40 ] = v. flags ;
226- o
227- }
228-
229- /// Decode a `ReaderPinValue` from a 41-byte slice.
230- pub fn decode_reader_pin ( bytes : & [ u8 ] ) -> Result < ReaderPinValue > {
231- if bytes. len ( ) != READER_PIN_VALUE_LEN {
232- return Err ( PagedbError :: corruption (
233- crate :: errors:: CorruptionDetail :: HeaderUnverifiable ,
234- ) ) ;
235- }
236- let read_u64 = |off : usize | {
237- let mut b = [ 0u8 ; 8 ] ;
238- b. copy_from_slice ( & bytes[ off..off + 8 ] ) ;
239- u64:: from_le_bytes ( b)
240- } ;
241- Ok ( ReaderPinValue {
242- commit_id : read_u64 ( 0 ) ,
243- root_page_id : read_u64 ( 8 ) ,
244- catalog_root_page_id : read_u64 ( 16 ) ,
245- free_list_root_page_id : read_u64 ( 24 ) ,
246- expires_unix_seconds : read_u64 ( 32 ) ,
247- flags : bytes[ 40 ] ,
248- } )
249- }
250-
251165 /// Counter row key: `[0x02] || name_bytes`. Rejects names longer than
252166 /// `MAX_SEGMENT_NAME_LEN`. Counter rows are per-`Db`, not per-realm.
253167 pub fn counter_key ( name : & [ u8 ] ) -> Result < Vec < u8 > > {
0 commit comments