@@ -27,7 +27,7 @@ use crate::{
27
27
catalog:: manifest:: { File , Manifest } ,
28
28
handlers:: http:: cluster:: INTERNAL_STREAM_NAME ,
29
29
parseable:: PARSEABLE ,
30
- storage:: { ObjectStorage , ObjectStorageError } ,
30
+ storage:: { ObjectStorage , ObjectStorageError , field_stats :: DATASET_STATS_STREAM_NAME } ,
31
31
utils:: { extract_datetime, human_size:: bytes_to_human_size} ,
32
32
validator:: error:: HotTierValidationError ,
33
33
} ;
@@ -252,6 +252,11 @@ impl HotTierManager {
252
252
253
253
///sync the hot tier files from S3 to the hot tier directory for all streams
254
254
async fn sync_hot_tier ( & self ) -> Result < ( ) , HotTierError > {
255
+ // Before syncing, check if pstats stream was created and needs hot tier
256
+ if let Err ( e) = self . create_pstats_hot_tier ( ) . await {
257
+ tracing:: trace!( "Skipping pstats hot tier creation because of error: {e}" ) ;
258
+ }
259
+
255
260
let mut sync_hot_tier_tasks = FuturesUnordered :: new ( ) ;
256
261
for stream in PARSEABLE . streams . list ( ) {
257
262
if self . check_stream_hot_tier_exists ( & stream) {
@@ -708,6 +713,30 @@ impl HotTierManager {
708
713
Ok ( ( ) )
709
714
}
710
715
716
+ /// Creates hot tier for pstats internal stream if the stream exists in storage
717
+ async fn create_pstats_hot_tier ( & self ) -> Result < ( ) , HotTierError > {
718
+ // Check if pstats hot tier already exists
719
+ if !self . check_stream_hot_tier_exists ( DATASET_STATS_STREAM_NAME ) {
720
+ // Check if pstats stream exists in storage by attempting to load it
721
+ if PARSEABLE
722
+ . check_or_load_stream ( DATASET_STATS_STREAM_NAME )
723
+ . await
724
+ {
725
+ let mut stream_hot_tier = StreamHotTier {
726
+ version : Some ( CURRENT_HOT_TIER_VERSION . to_string ( ) ) ,
727
+ size : MIN_STREAM_HOT_TIER_SIZE_BYTES ,
728
+ used_size : 0 ,
729
+ available_size : MIN_STREAM_HOT_TIER_SIZE_BYTES ,
730
+ oldest_date_time_entry : None ,
731
+ } ;
732
+ self . put_hot_tier ( DATASET_STATS_STREAM_NAME , & mut stream_hot_tier)
733
+ . await ?;
734
+ }
735
+ }
736
+
737
+ Ok ( ( ) )
738
+ }
739
+
711
740
/// Get the disk usage for the hot tier storage path. If we have a three disk paritions
712
741
/// mounted as follows:
713
742
/// 1. /
0 commit comments