@@ -350,7 +350,7 @@ impl Replicator {
350350
351351 let mut join_set = JoinSet :: new ( ) ;
352352
353- let ( frames_outbox, mut frames_inbox) = tokio:: sync:: mpsc:: channel ( 64 ) ;
353+ let ( frames_outbox, mut frames_inbox) = tokio:: sync:: mpsc:: unbounded_channel ( ) ;
354354 let _local_backup = {
355355 let mut copier = WalCopier :: new (
356356 bucket. clone ( ) ,
@@ -433,24 +433,28 @@ impl Replicator {
433433
434434 let db_name = db_name. clone ( ) ;
435435 join_set. spawn ( async move {
436- let fpath = format ! ( "{}/{}" , bucket, req. path) ;
437- let body = ByteStream :: from_path ( & fpath) . await . unwrap ( ) ;
438- let start_time = Instant :: now ( ) ;
439- let response = client
440- . put_object ( )
441- . bucket ( bucket)
442- . key ( req. path )
443- . body ( body)
444- . send ( )
445- . await ;
446- Self :: record_s3_write_time ( & db_name, start_time. elapsed ( ) ) ;
447- if let Err ( e) = response {
448- tracing:: error!( "Failed to send {} to S3: {}" , fpath, e) ;
449- } else {
450- tokio:: fs:: remove_file ( & fpath) . await . unwrap ( ) ;
451- let elapsed = Instant :: now ( ) - start;
452- tracing:: debug!( "Uploaded to S3: {} in {:?}" , fpath, elapsed) ;
436+ let fpath = format ! ( "{}/{}" , & bucket, & req. path) ;
437+ loop {
438+ let start_time = Instant :: now ( ) ;
439+ let body = ByteStream :: from_path ( & fpath) . await . unwrap ( ) ;
440+ let response = client
441+ . put_object ( )
442+ . bucket ( & bucket)
443+ . key ( & req. path )
444+ . body ( body)
445+ . send ( )
446+ . await ;
447+ Self :: record_s3_write_time ( & db_name, start_time. elapsed ( ) ) ;
448+ if let Err ( e) = response {
449+ tracing:: error!( "Failed to send {} to S3: {}, will retry after 1 second" , fpath, e) ;
450+ tokio:: time:: sleep ( Duration :: from_millis ( 1000 ) ) . await ;
451+ } else {
452+ break ;
453+ }
453454 }
455+ tokio:: fs:: remove_file ( & fpath) . await . unwrap ( ) ;
456+ let elapsed = Instant :: now ( ) - start;
457+ tracing:: debug!( "Uploaded to S3: {} in {:?}" , fpath, elapsed) ;
454458 if let Some ( frames) = req. frames {
455459 let mut up = upload_progress. lock ( ) . await ;
456460 up. update ( * frames. start ( ) , * frames. end ( ) ) ;
0 commit comments