@@ -426,16 +426,16 @@ pub trait ObjectStorage: Sync + 'static {
426426 . await
427427 }
428428
429- async fn sync ( & self ) -> Result < ( ) , ObjectStorageError > {
429+ async fn sync ( & self , shutdown_signal : bool ) -> Result < ( ) , ObjectStorageError > {
430430 if !Path :: new ( & CONFIG . staging_dir ( ) ) . exists ( ) {
431431 return Ok ( ( ) ) ;
432432 }
433-
433+
434434 let streams = STREAM_INFO . list_streams ( ) ;
435-
435+
436436 let cache_manager = LocalCacheManager :: global ( ) ;
437437 let mut cache_updates: HashMap < & String , Vec < _ > > = HashMap :: new ( ) ;
438-
438+
439439 for stream in & streams {
440440 let cache_enabled = STREAM_INFO
441441 . get_cache_enabled ( stream)
@@ -452,9 +452,10 @@ pub trait ObjectStorage: Sync + 'static {
452452 & dir,
453453 time_partition,
454454 custom_partition. clone ( ) ,
455+ shutdown_signal,
455456 )
456457 . map_err ( |err| ObjectStorageError :: UnhandledError ( Box :: new ( err) ) ) ?;
457-
458+
458459 if let Some ( schema) = schema {
459460 let static_schema_flag = STREAM_INFO
460461 . get_static_schema_flag ( stream)
@@ -463,14 +464,18 @@ pub trait ObjectStorage: Sync + 'static {
463464 commit_schema_to_storage ( stream, schema) . await ?;
464465 }
465466 }
467+
466468 let parquet_files = dir. parquet_files ( ) ;
467-
468469 for file in parquet_files {
469470 let filename = file
470471 . file_name ( )
471472 . expect ( "only parquet files are returned by iterator" )
472473 . to_str ( )
473474 . expect ( "filename is valid string" ) ;
475+
476+ // Log the filename being processed
477+ log:: debug!( "Processing file: {}" , filename) ;
478+
474479 let mut file_date_part = filename. split ( '.' ) . collect :: < Vec < & str > > ( ) [ 0 ] ;
475480 file_date_part = file_date_part. split ( '=' ) . collect :: < Vec < & str > > ( ) [ 1 ] ;
476481 let compressed_size = file. metadata ( ) . map_or ( 0 , |meta| meta. len ( ) ) ;
@@ -484,7 +489,7 @@ pub trait ObjectStorage: Sync + 'static {
484489 . with_label_values ( & [ "data" , stream, "parquet" ] )
485490 . add ( compressed_size as i64 ) ;
486491 let mut file_suffix = str:: replacen ( filename, "." , "/" , 3 ) ;
487-
492+
488493 let custom_partition_clone = custom_partition. clone ( ) ;
489494 if custom_partition_clone. is_some ( ) {
490495 let custom_partition_fields = custom_partition_clone. unwrap ( ) ;
@@ -493,8 +498,15 @@ pub trait ObjectStorage: Sync + 'static {
493498 file_suffix =
494499 str:: replacen ( filename, "." , "/" , 3 + custom_partition_list. len ( ) ) ;
495500 }
501+
496502 let stream_relative_path = format ! ( "{stream}/{file_suffix}" ) ;
497- self . upload_file ( & stream_relative_path, & file) . await ?;
503+
504+ // Try uploading the file, handle potential errors without breaking the loop
505+ if let Err ( e) = self . upload_file ( & stream_relative_path, & file) . await {
506+ log:: error!( "Failed to upload file {}: {:?}" , filename, e) ;
507+ continue ; // Skip to the next file
508+ }
509+
498510 let absolute_path = self
499511 . absolute_url ( RelativePath :: from_path ( & stream_relative_path) . unwrap ( ) )
500512 . to_string ( ) ;
@@ -512,28 +524,30 @@ pub trait ObjectStorage: Sync + 'static {
512524 }
513525 }
514526 }
515-
527+
528+ // Cache management logic
516529 if let Some ( manager) = cache_manager {
517530 let cache_updates = cache_updates
518531 . into_iter ( )
519532 . map ( |( key, value) | ( key. to_owned ( ) , value) )
520533 . collect_vec ( ) ;
521-
534+
522535 tokio:: spawn ( async move {
523536 for ( stream, files) in cache_updates {
524537 for ( storage_path, file) in files {
525- manager
538+ if let Err ( e ) = manager
526539 . move_to_cache ( & stream, storage_path, file. to_owned ( ) )
527- . await
528- . unwrap ( )
540+ . await {
541+ log:: error!( "Failed to move file to cache: {:?}" , e) ;
542+ }
529543 }
530544 }
531545 } ) ;
532546 }
533-
547+
534548 Ok ( ( ) )
535549 }
536-
550+
537551 // pick a better name
538552 fn get_bucket_name ( & self ) -> String ;
539553}
0 commit comments