@@ -133,8 +133,26 @@ fn maybe_store_segment<S: Storage>(
133
133
storage. store ( namespace, seg, None , cb) ;
134
134
} else {
135
135
// 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
+ ) ;
138
156
}
139
157
}
140
158
@@ -245,10 +263,15 @@ where
245
263
// will think that this is a wal file, but it's in fact a directory and it will not like
246
264
// it.
247
265
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
+ ) ) ;
249
270
self . io . create_dir_all ( & wals_path) ?;
250
271
// 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 ( ) ;
252
275
253
276
// we only checkpoint durable frame_no so this is a good first estimate without an actual
254
277
// network call.
@@ -268,9 +291,12 @@ where
268
291
269
292
let file = self . io . open ( false , true , true , entry. path ( ) ) ?;
270
293
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
+ ) ? {
274
300
list. push ( sealed. clone ( ) ) ;
275
301
maybe_store_segment (
276
302
self . storage . as_ref ( ) ,
@@ -526,9 +552,7 @@ where
526
552
return Ok ( ( ) ) ;
527
553
}
528
554
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" ) ) ;
532
556
533
557
let segment_file = self . io . open ( true , true , true , & path) ?;
534
558
let salt = self . io . with_rng ( |rng| rng. gen ( ) ) ;
0 commit comments