File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ use fst::MapBuilder;
1414use parking_lot:: { Mutex , RwLock } ;
1515use roaring:: RoaringBitmap ;
1616use tokio_stream:: Stream ;
17+ use uuid:: Uuid ;
1718use zerocopy:: little_endian:: U32 ;
1819use zerocopy:: { AsBytes , FromZeroes } ;
1920
@@ -54,6 +55,7 @@ impl<F> CurrentSegment<F> {
5455 db_size : u32 ,
5556 tail : Arc < SegmentList < SealedSegment < F > > > ,
5657 salt : u32 ,
58+ log_id : Uuid ,
5759 ) -> Result < Self >
5860 where
5961 F : FileExt ,
@@ -70,6 +72,7 @@ impl<F> CurrentSegment<F> {
7072 version : LIBSQL_WAL_VERSION . into ( ) ,
7173 salt : salt. into ( ) ,
7274 page_size : LIBSQL_PAGE_SIZE . into ( ) ,
75+ log_id : log_id. as_u128 ( ) . into ( ) ,
7376 } ;
7477
7578 header. recompute_checksum ( ) ;
@@ -88,6 +91,10 @@ impl<F> CurrentSegment<F> {
8891 } )
8992 }
9093
94+ pub fn log_id ( & self ) -> Uuid {
95+ Uuid :: from_u128 ( self . header . lock ( ) . log_id . get ( ) )
96+ }
97+
9198 pub fn is_empty ( & self ) -> bool {
9299 self . count_committed ( ) == 0
93100 }
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ use std::mem::size_of;
1515use std:: num:: NonZeroU64 ;
1616use std:: sync:: Arc ;
1717
18- use zerocopy:: byteorder:: little_endian:: { U16 , U32 , U64 } ;
18+ use zerocopy:: byteorder:: little_endian:: { U128 , U16 , U32 , U64 } ;
1919use zerocopy:: AsBytes ;
2020
2121use crate :: error:: { Error , Result } ;
@@ -63,6 +63,7 @@ pub struct SegmentHeader {
6363 /// right now we only support 4096, but if se decided to support other sizes,
6464 /// we could do it without changing the header
6565 pub page_size : U16 ,
66+ pub log_id : U128 ,
6667
6768 /// checksum of the header fields, excluding the checksum itself. This field must be the last
6869 pub header_cheksum : U32 ,
Original file line number Diff line number Diff line change 11use std:: collections:: BTreeMap ;
2- use std:: sync:: atomic:: { AtomicBool , AtomicU64 , Ordering } ;
2+ use std:: sync:: atomic:: { AtomicBool , AtomicU64 , AtomicUsize , Ordering } ;
33use std:: sync:: Arc ;
44use std:: time:: Instant ;
55
66use arc_swap:: ArcSwap ;
77use crossbeam:: deque:: Injector ;
88use crossbeam:: sync:: Unparker ;
99use parking_lot:: { Mutex , MutexGuard } ;
10- use tokio:: sync:: mpsc;
10+ use tokio:: sync:: { mpsc, watch} ;
11+ use uuid:: Uuid ;
1112
1213use crate :: checkpointer:: CheckpointMessage ;
1314use crate :: error:: { Error , Result } ;
@@ -83,10 +84,18 @@ impl<IO: Io> SharedWal<IO> {
8384 Ok ( ( ) )
8485 }
8586
87+ pub fn new_frame_notifier ( & self ) -> watch:: Receiver < u64 > {
88+ self . new_frame_notifier . subscribe ( )
89+ }
90+
8691 pub fn db_size ( & self ) -> u32 {
8792 self . current . load ( ) . db_size ( )
8893 }
8994
95+ pub fn log_id ( & self ) -> Uuid {
96+ self . current . load ( ) . log_id ( )
97+ }
98+
9099 #[ tracing:: instrument( skip_all) ]
91100 pub fn begin_read ( & self , conn_id : u64 ) -> ReadTransaction < IO :: File > {
92101 // FIXME: this is not enough to just increment the counter, we must make sure that the segment
You can’t perform that action at this time.
0 commit comments