@@ -39,6 +39,7 @@ impl SyncContext {
3939 Ok ( me)
4040 }
4141
42+ #[ tracing:: instrument( skip( self , frame) ) ]
4243 pub ( crate ) async fn push_one_frame (
4344 & mut self ,
4445 frame : Bytes ,
@@ -52,14 +53,18 @@ impl SyncContext {
5253 frame_no,
5354 frame_no + 1
5455 ) ;
55- let max_frame_no = self . push_with_retry ( uri, frame, self . max_retries ) . await ?;
56+ tracing:: debug!( "pushing frame" ) ;
57+
58+ let durable_frame_num = self . push_with_retry ( uri, frame, self . max_retries ) . await ?;
59+
60+ tracing:: debug!( ?durable_frame_num, "frame successfully pushed" ) ;
5661
5762 // Update our last known max_frame_no from the server.
58- self . durable_frame_num = max_frame_no ;
63+ self . durable_frame_num = durable_frame_num ;
5964
6065 self . write_metadata ( ) . await ?;
6166
62- Ok ( max_frame_no )
67+ Ok ( durable_frame_num )
6368 }
6469
6570 async fn push_with_retry ( & self , uri : String , frame : Bytes , max_retries : usize ) -> Result < u32 > {
@@ -80,9 +85,6 @@ impl SyncContext {
8085 None => { }
8186 }
8287
83- // TODO(lucio): convert this to use bytes to make this clone cheap, it should be
84- // to possible use BytesMut when reading frames from the WAL and efficiently use Bytes
85- // from that.
8688 let req = req. body ( frame. clone ( ) . into ( ) ) . expect ( "valid body" ) ;
8789
8890 let res = self . client . request ( req) . await . unwrap ( ) ;
@@ -129,6 +131,11 @@ impl SyncContext {
129131 async fn read_metadata ( & mut self ) -> Result < ( ) > {
130132 let path = format ! ( "{}-info" , self . db_path) ;
131133
134+ if !std:: fs:: exists ( & path) . unwrap ( ) {
135+ tracing:: debug!( "no metadata info file found" ) ;
136+ return Ok ( ( ) ) ;
137+ }
138+
132139 let contents = tokio:: fs:: read ( & path) . await . unwrap ( ) ;
133140
134141 let metadata = serde_json:: from_slice :: < MetadataJson > ( & contents[ ..] ) . unwrap ( ) ;
0 commit comments