File tree Expand file tree Collapse file tree 1 file changed +21
-6
lines changed
Expand file tree Collapse file tree 1 file changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -319,13 +319,28 @@ impl Database {
319319 version > 0 && version % 40 == 0
320320 } ;
321321
322- // Checkpoint outside the write lock if needed
322+ // Checkpoint in the background if needed
323323 if should_checkpoint {
324- // Take a read lock for checkpointing
325- let table = table_ref. read ( ) . await ;
326- let version = table. version ( ) ;
327- info ! ( "Checkpointing Delta table at version {}" , version) ;
328- checkpoints:: create_checkpoint ( & table, None ) . await ?;
324+ // Clone the necessary resources for the background task
325+ let table_ref_clone = Arc :: clone ( & table_ref) ;
326+
327+ // Spawn a background task to perform checkpointing
328+ tokio:: spawn ( async move {
329+ // Take a read lock for checkpointing
330+ let result = async {
331+ let table = table_ref_clone. read ( ) . await ;
332+ let version = table. version ( ) ;
333+ info ! ( "Starting background checkpointing for Delta table at version {}" , version) ;
334+ checkpoints:: create_checkpoint ( & table, None ) . await
335+ } . await ;
336+
337+ match result {
338+ Ok ( _) => info ! ( "Background checkpointing completed successfully" ) ,
339+ Err ( e) => error ! ( "Background checkpointing failed: {}" , e) ,
340+ }
341+ } ) ;
342+
343+ info ! ( "Checkpoint scheduled in background" ) ;
329344 }
330345
331346 Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments