@@ -133,8 +133,26 @@ fn maybe_store_segment<S: Storage>(
133133 storage. store ( namespace, seg, None , cb) ;
134134 } else {
135135 // segment can be checkpointed right away.
136- let _ = notifier. blocking_send ( CheckpointMessage :: Namespace ( namespace. clone ( ) ) ) ;
137- tracing:: debug!( segment_end = seg. last_committed( ) , durable_frame_no = * durable_frame_no. lock( ) , "segment doesn't contain any new data" ) ;
136+ // FIXME: this is only necessary because some tests call this method in an async context.
137+ #[ cfg( debug_assertions) ]
138+ {
139+ let namespace = namespace. clone ( ) ;
140+ let notifier = notifier. clone ( ) ;
141+ tokio:: spawn ( async move {
142+ let _ = notifier. send ( CheckpointMessage :: Namespace ( namespace) ) . await ;
143+ } ) ;
144+ }
145+
146+ #[ cfg( not( debug_assertions) ) ]
147+ {
148+ let _ = notifier. blocking_send ( CheckpointMessage :: Namespace ( namespace. clone ( ) ) ) ;
149+ }
150+
151+ tracing:: debug!(
152+ segment_end = seg. last_committed( ) ,
153+ durable_frame_no = * durable_frame_no. lock( ) ,
154+ "segment doesn't contain any new data"
155+ ) ;
138156 }
139157}
140158
@@ -245,10 +263,15 @@ where
245263 // will think that this is a wal file, but it's in fact a directory and it will not like
246264 // it.
247265 let mut wals_path = db_path. to_owned ( ) ;
248- wals_path. set_file_name ( format ! ( "{}-wal" , db_path. file_name( ) . unwrap( ) . to_str( ) . unwrap( ) ) ) ;
266+ wals_path. set_file_name ( format ! (
267+ "{}-wal" ,
268+ db_path. file_name( ) . unwrap( ) . to_str( ) . unwrap( )
269+ ) ) ;
249270 self . io . create_dir_all ( & wals_path) ?;
250271 // TODO: handle that with abstract io
251- let dir = walkdir:: WalkDir :: new ( & wals_path) . sort_by_file_name ( ) . into_iter ( ) ;
272+ let dir = walkdir:: WalkDir :: new ( & wals_path)
273+ . sort_by_file_name ( )
274+ . into_iter ( ) ;
252275
253276 // we only checkpoint durable frame_no so this is a good first estimate without an actual
254277 // network call.
@@ -268,9 +291,12 @@ where
268291
269292 let file = self . io . open ( false , true , true , entry. path ( ) ) ?;
270293
271- if let Some ( sealed) =
272- SealedSegment :: open ( file. into ( ) , entry. path ( ) . to_path_buf ( ) , Default :: default ( ) , self . io . now ( ) ) ?
273- {
294+ if let Some ( sealed) = SealedSegment :: open (
295+ file. into ( ) ,
296+ entry. path ( ) . to_path_buf ( ) ,
297+ Default :: default ( ) ,
298+ self . io . now ( ) ,
299+ ) ? {
274300 list. push ( sealed. clone ( ) ) ;
275301 maybe_store_segment (
276302 self . storage . as_ref ( ) ,
@@ -526,9 +552,7 @@ where
526552 return Ok ( ( ) ) ;
527553 }
528554 let start_frame_no = current. next_frame_no ( ) ;
529- let path = shared
530- . wals_path
531- . join ( format ! ( "{start_frame_no:020}.seg" ) ) ;
555+ let path = shared. wals_path . join ( format ! ( "{start_frame_no:020}.seg" ) ) ;
532556
533557 let segment_file = self . io . open ( true , true , true , & path) ?;
534558 let salt = self . io . with_rng ( |rng| rng. gen ( ) ) ;
0 commit comments