@@ -645,10 +645,14 @@ cfg_sync! {
645645 let mut bg_abort: Option <std:: sync:: Arc <crate :: sync:: DropAbort >> = None ;
646646
647647 if let Some ( sync_interval) = sync_interval {
648+ let sync_span = tracing:: debug_span!( "sync_interval" ) ;
649+ let _enter = sync_span. enter( ) ;
650+
648651 let sync_ctx = db. sync_ctx. as_ref( ) . unwrap( ) . clone( ) ;
649652 {
650653 let mut ctx = sync_ctx. lock( ) . await ;
651654 crate :: sync:: bootstrap_db( & mut ctx) . await ?;
655+ tracing:: debug!( "finished bootstrap with sync interval" ) ;
652656 }
653657
654658 // db.connect creates a local db file, so it is important that we always call
@@ -657,8 +661,15 @@ cfg_sync! {
657661 let conn = db. connect( ) ?;
658662 let jh = tokio:: spawn(
659663 async move {
664+ let mut interval = tokio:: time:: interval( sync_interval) ;
665+
660666 loop {
661- tracing:: trace!( "trying to sync" ) ;
667+ tracing:: info!( "trying to sync" ) ;
668+
669+ // NOTE(levy): Sleeping after the sync proceature will cause a delay
670+ // when aborting. I have no idea why.
671+ interval. tick( ) . await ;
672+
662673 let mut ctx = sync_ctx. lock( ) . await ;
663674 if remote_writes {
664675 if let Err ( e) = crate :: sync:: try_pull( & mut ctx, & conn) . await {
@@ -669,10 +680,9 @@ cfg_sync! {
669680 tracing:: error!( "sync error: {}" , e) ;
670681 }
671682 }
672- tokio:: time:: sleep( sync_interval) . await ;
673683 }
674684 }
675- . instrument( tracing:: info_span !( "sync_interval " ) ) ,
685+ . instrument( tracing:: debug_span !( "sync interval thread " ) ) ,
676686 ) ;
677687
678688 bg_abort. replace( std:: sync:: Arc :: new( crate :: sync:: DropAbort ( jh. abort_handle( ) ) ) ) ;
0 commit comments