@@ -62,15 +62,13 @@ use super::{
6262 writer:: Writer ,
6363 StagingError ,
6464 } ,
65- LogStream ,
65+ LogStream , ARROW_FILE_EXTENSION ,
6666} ;
6767
6868#[ derive( Debug , thiserror:: Error ) ]
6969#[ error( "Stream not found: {0}" ) ]
7070pub struct StreamNotFound ( pub String ) ;
7171
72- const ARROW_FILE_EXTENSION : & str = "data.arrows" ;
73-
7472pub type StreamRef = Arc < Stream > ;
7573
7674/// Gets the unix timestamp for the minute as described by the `SystemTime`
@@ -165,7 +163,7 @@ impl Stream {
165163 hostname. push_str ( id) ;
166164 }
167165 let filename = format ! (
168- "{stream_hash}.date={}.hour={:02}.minute={}.{}{hostname}.{ARROW_FILE_EXTENSION}" ,
166+ "{stream_hash}.date={}.hour={:02}.minute={}.{}{hostname}.data. {ARROW_FILE_EXTENSION}" ,
169167 parsed_timestamp. date( ) ,
170168 parsed_timestamp. hour( ) ,
171169 minute_to_slot( parsed_timestamp. minute( ) , OBJECT_STORE_DATA_GRANULARITY ) . unwrap( ) ,
@@ -495,10 +493,12 @@ impl Stream {
495493 }
496494 writer. close ( ) ?;
497495
498- if part_file. metadata ( ) . unwrap ( ) . len ( ) < parquet:: file:: FOOTER_SIZE as u64 {
496+ if part_file. metadata ( ) . expect ( "File was just created" ) . len ( )
497+ < parquet:: file:: FOOTER_SIZE as u64
498+ {
499499 error ! (
500- "Invalid parquet file {:?} detected for stream {}, removing it" ,
501- & part_path , & self . stream_name
500+ "Invalid parquet file {part_path :?} detected for stream {}, removing it" ,
501+ & self . stream_name
502502 ) ;
503503 remove_file ( part_path) . unwrap ( ) ;
504504 } else {
@@ -510,15 +510,22 @@ impl Stream {
510510 }
511511
512512 for file in arrow_files {
513- // warn!("file-\n{file:?}\n");
514- let file_size = file. metadata ( ) . unwrap ( ) . len ( ) ;
515- let file_type = file. extension ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
516- if remove_file ( file. clone ( ) ) . is_err ( ) {
513+ let file_size = match file. metadata ( ) {
514+ Ok ( meta) => meta. len ( ) ,
515+ Err ( err) => {
516+ warn ! (
517+ "File ({}) not found; Error = {err}" ,
518+ file. display( )
519+ ) ;
520+ continue ;
521+ }
522+ } ;
523+ if remove_file ( & file) . is_err ( ) {
517524 error ! ( "Failed to delete file. Unstable state" ) ;
518525 process:: abort ( )
519526 }
520527 metrics:: STORAGE_SIZE
521- . with_label_values ( & [ "staging" , & self . stream_name , file_type ] )
528+ . with_label_values ( & [ "staging" , & self . stream_name , ARROW_FILE_EXTENSION ] )
522529 . sub ( file_size as i64 ) ;
523530 }
524531 }
@@ -883,7 +890,7 @@ mod tests {
883890 ) ;
884891
885892 let expected_path = staging. data_path . join ( format ! (
886- "{stream_hash}.date={}.hour={:02}.minute={}.{}.{ARROW_FILE_EXTENSION}" ,
893+ "{stream_hash}.date={}.hour={:02}.minute={}.{}.data. {ARROW_FILE_EXTENSION}" ,
887894 parsed_timestamp. date( ) ,
888895 parsed_timestamp. hour( ) ,
889896 minute_to_slot( parsed_timestamp. minute( ) , OBJECT_STORE_DATA_GRANULARITY ) . unwrap( ) ,
@@ -917,7 +924,7 @@ mod tests {
917924 ) ;
918925
919926 let expected_path = staging. data_path . join ( format ! (
920- "{stream_hash}.date={}.hour={:02}.minute={}.key1=value1.key2=value2.{}.{ARROW_FILE_EXTENSION}" ,
927+ "{stream_hash}.date={}.hour={:02}.minute={}.key1=value1.key2=value2.{}.data. {ARROW_FILE_EXTENSION}" ,
921928 parsed_timestamp. date( ) ,
922929 parsed_timestamp. hour( ) ,
923930 minute_to_slot( parsed_timestamp. minute( ) , OBJECT_STORE_DATA_GRANULARITY ) . unwrap( ) ,
0 commit comments