@@ -39,6 +39,7 @@ impl SyncContext {
39
39
Ok ( me)
40
40
}
41
41
42
+ #[ tracing:: instrument( skip( self , frame) ) ]
42
43
pub ( crate ) async fn push_one_frame (
43
44
& mut self ,
44
45
frame : Bytes ,
@@ -52,14 +53,18 @@ impl SyncContext {
52
53
frame_no,
53
54
frame_no + 1
54
55
) ;
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" ) ;
56
61
57
62
// 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 ;
59
64
60
65
self . write_metadata ( ) . await ?;
61
66
62
- Ok ( max_frame_no )
67
+ Ok ( durable_frame_num )
63
68
}
64
69
65
70
async fn push_with_retry ( & self , uri : String , frame : Bytes , max_retries : usize ) -> Result < u32 > {
@@ -80,9 +85,6 @@ impl SyncContext {
80
85
None => { }
81
86
}
82
87
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.
86
88
let req = req. body ( frame. clone ( ) . into ( ) ) . expect ( "valid body" ) ;
87
89
88
90
let res = self . client . request ( req) . await . unwrap ( ) ;
@@ -129,6 +131,11 @@ impl SyncContext {
129
131
async fn read_metadata ( & mut self ) -> Result < ( ) > {
130
132
let path = format ! ( "{}-info" , self . db_path) ;
131
133
134
+ if !std:: fs:: exists ( & path) . unwrap ( ) {
135
+ tracing:: debug!( "no metadata info file found" ) ;
136
+ return Ok ( ( ) ) ;
137
+ }
138
+
132
139
let contents = tokio:: fs:: read ( & path) . await . unwrap ( ) ;
133
140
134
141
let metadata = serde_json:: from_slice :: < MetadataJson > ( & contents[ ..] ) . unwrap ( ) ;
0 commit comments