@@ -121,10 +121,13 @@ where
121
121
let notifier = self . checkpoint_notifier . clone ( ) ;
122
122
let namespace = shared. namespace ( ) . clone ( ) ;
123
123
let durable_frame_no = shared. durable_frame_no . clone ( ) ;
124
- let cb: OnStoreCallback = Box :: new ( move |fno| Box :: pin ( async move {
125
- update_durable ( fno, notifier, durable_frame_no, namespace) . await ;
126
- } ) ) ;
127
- self . storage . store ( & shared. namespace , sealed. clone ( ) , None , cb) ;
124
+ let cb: OnStoreCallback = Box :: new ( move |fno| {
125
+ Box :: pin ( async move {
126
+ update_durable ( fno, notifier, durable_frame_no, namespace) . await ;
127
+ } )
128
+ } ) ;
129
+ self . storage
130
+ . store ( & shared. namespace , sealed. clone ( ) , None , cb) ;
128
131
new. tail ( ) . push ( sealed) ;
129
132
}
130
133
@@ -140,7 +143,7 @@ async fn update_durable(
140
143
notifier : mpsc:: Sender < CheckpointMessage > ,
141
144
durable_frame_no_slot : Arc < Mutex < u64 > > ,
142
145
namespace : NamespaceName ,
143
- ) {
146
+ ) {
144
147
{
145
148
let mut g = durable_frame_no_slot. lock ( ) ;
146
149
if * g < new_durable {
@@ -180,23 +183,18 @@ where
180
183
}
181
184
182
185
let action = match self . opened . entry ( namespace. clone ( ) ) {
183
- dashmap:: Entry :: Occupied ( e) => {
184
- match e. get ( ) {
185
- Slot :: Wal ( shared) => return Ok ( shared. clone ( ) ) ,
186
- Slot :: Building ( wait, _) => {
187
- Err ( wait. clone ( ) )
188
- } ,
189
- }
186
+ dashmap:: Entry :: Occupied ( e) => match e. get ( ) {
187
+ Slot :: Wal ( shared) => return Ok ( shared. clone ( ) ) ,
188
+ Slot :: Building ( wait, _) => Err ( wait. clone ( ) ) ,
190
189
} ,
191
190
dashmap:: Entry :: Vacant ( e) => {
192
191
let notifier = Arc :: new ( ( Condvar :: new ( ) , Mutex :: new ( false ) ) ) ;
193
192
let async_notifier = Arc :: new ( Notify :: new ( ) ) ;
194
193
e. insert ( Slot :: Building ( notifier. clone ( ) , async_notifier. clone ( ) ) ) ;
195
194
Ok ( ( notifier, async_notifier) )
196
- } ,
195
+ }
197
196
} ;
198
197
199
-
200
198
match action {
201
199
Ok ( ( notifier, async_notifier) ) => {
202
200
// if try_open succedded, then the slot was updated and contains the shared wal, if it
@@ -216,8 +214,8 @@ where
216
214
cond. 0
217
215
. wait_while ( & mut cond. 1 . lock ( ) , |ready : & mut bool | !* ready) ;
218
216
// the slot was updated: try again
219
- continue
220
- } ,
217
+ continue ;
218
+ }
221
219
}
222
220
}
223
221
}
@@ -254,11 +252,13 @@ where
254
252
SealedSegment :: open ( file. into ( ) , entry. path ( ) . to_path_buf ( ) , Default :: default ( ) ) ?
255
253
{
256
254
let notifier = self . checkpoint_notifier . clone ( ) ;
257
- let ns = namespace. clone ( ) ;
255
+ let ns = namespace. clone ( ) ;
258
256
let durable_frame_no = durable_frame_no. clone ( ) ;
259
- let cb: OnStoreCallback = Box :: new ( move |fno| Box :: pin ( async move {
260
- update_durable ( fno, notifier, durable_frame_no, ns) . await ;
261
- } ) ) ;
257
+ let cb: OnStoreCallback = Box :: new ( move |fno| {
258
+ Box :: pin ( async move {
259
+ update_durable ( fno, notifier, durable_frame_no, ns) . await ;
260
+ } )
261
+ } ) ;
262
262
// TODO: pass config override here
263
263
self . storage . store ( & namespace, sealed. clone ( ) , None , cb) ;
264
264
tail. push ( sealed) ;
@@ -311,7 +311,8 @@ where
311
311
shutdown : false . into ( ) ,
312
312
} ) ;
313
313
314
- self . opened . insert ( namespace. clone ( ) , Slot :: Wal ( shared. clone ( ) ) ) ;
314
+ self . opened
315
+ . insert ( namespace. clone ( ) , Slot :: Wal ( shared. clone ( ) ) ) ;
315
316
316
317
return Ok ( shared) ;
317
318
}
@@ -321,7 +322,6 @@ where
321
322
pub async fn shutdown ( self : Arc < Self > ) -> Result < ( ) > {
322
323
self . shutdown . store ( true , Ordering :: SeqCst ) ;
323
324
324
-
325
325
let mut join_set = JoinSet :: < Result < ( ) > > :: new ( ) ;
326
326
let semaphore = Arc :: new ( Semaphore :: new ( 8 ) ) ;
327
327
for item in self . opened . iter ( ) {
@@ -347,20 +347,23 @@ where
347
347
348
348
Ok ( ( ) )
349
349
} ) ;
350
- break
351
- } ,
350
+ break ;
351
+ }
352
352
Slot :: Building ( _, notify) => {
353
353
// wait for shared to finish building
354
354
notify. notified ( ) . await ;
355
- } ,
355
+ }
356
356
}
357
357
}
358
358
}
359
359
360
360
while join_set. join_next ( ) . await . is_some ( ) { }
361
361
362
362
// wait for checkpointer to exit
363
- let _ = self . checkpoint_notifier . send ( CheckpointMessage :: Shutdown ) . await ;
363
+ let _ = self
364
+ . checkpoint_notifier
365
+ . send ( CheckpointMessage :: Shutdown )
366
+ . await ;
364
367
self . checkpoint_notifier . closed ( ) . await ;
365
368
366
369
Ok ( ( ) )
0 commit comments