@@ -645,10 +645,14 @@ cfg_sync! {
645
645
let mut bg_abort: Option <std:: sync:: Arc <crate :: sync:: DropAbort >> = None ;
646
646
647
647
if let Some ( sync_interval) = sync_interval {
648
+ let sync_span = tracing:: debug_span!( "sync_interval" ) ;
649
+ let _enter = sync_span. enter( ) ;
650
+
648
651
let sync_ctx = db. sync_ctx. as_ref( ) . unwrap( ) . clone( ) ;
649
652
{
650
653
let mut ctx = sync_ctx. lock( ) . await ;
651
654
crate :: sync:: bootstrap_db( & mut ctx) . await ?;
655
+ tracing:: debug!( "finished bootstrap with sync interval" ) ;
652
656
}
653
657
654
658
// db.connect creates a local db file, so it is important that we always call
@@ -657,8 +661,13 @@ cfg_sync! {
657
661
let conn = db. connect( ) ?;
658
662
let jh = tokio:: spawn(
659
663
async move {
664
+ let mut interval = tokio:: time:: interval( sync_interval) ;
665
+
660
666
loop {
661
- tracing:: trace!( "trying to sync" ) ;
667
+ tracing:: info!( "trying to sync" ) ;
668
+
669
+ interval. tick( ) . await ;
670
+
662
671
let mut ctx = sync_ctx. lock( ) . await ;
663
672
if remote_writes {
664
673
if let Err ( e) = crate :: sync:: try_pull( & mut ctx, & conn) . await {
@@ -669,10 +678,9 @@ cfg_sync! {
669
678
tracing:: error!( "sync error: {}" , e) ;
670
679
}
671
680
}
672
- tokio:: time:: sleep( sync_interval) . await ;
673
681
}
674
682
}
675
- . instrument( tracing:: info_span !( "sync_interval " ) ) ,
683
+ . instrument( tracing:: debug_span !( "sync interval thread " ) ) ,
676
684
) ;
677
685
678
686
bg_abort. replace( std:: sync:: Arc :: new( crate :: sync:: DropAbort ( jh. abort_handle( ) ) ) ) ;
0 commit comments