Skip to content

Commit fb3fd21

Browse files
fix: removed use of environment var P_STORAGE_UPLOAD_INTERVAL (#653)
added const of 60 secs to be used for local to storage sync fixes #651
1 parent d795e8e commit fb3fd21

File tree

3 files changed

+8
-41
lines changed

3 files changed

+8
-41
lines changed

server/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ mod validator;
5050
use option::CONFIG;
5151

5252
use crate::localcache::LocalCacheManager;
53+
pub const STORAGE_UPLOAD_INTERVAL: u32 = 60;
5354

5455
#[actix_web::main]
5556
async fn main() -> anyhow::Result<()> {
@@ -129,7 +130,7 @@ fn object_store_sync() -> (JoinHandle<()>, oneshot::Receiver<()>, oneshot::Sende
129130
rt.block_on(async {
130131
let mut scheduler = AsyncScheduler::new();
131132
scheduler
132-
.every((CONFIG.parseable.upload_interval as u32).seconds())
133+
.every(STORAGE_UPLOAD_INTERVAL.seconds())
133134
// Extra time interval is added so that this schedular does not race with local sync.
134135
.plus(5u32.seconds())
135136
.run(|| async {

server/src/option.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,6 @@ pub struct Server {
215215
/// Size for local cache
216216
pub local_cache_size: u64,
217217

218-
/// Interval in seconds after which uncommited data would be
219-
/// uploaded to the storage platform.
220-
pub upload_interval: u64,
221-
222218
/// Username for the basic authentication on the server
223219
pub username: String,
224220

@@ -284,10 +280,6 @@ impl FromArgMatches for Server {
284280
.get_one::<u64>(Self::CACHE_SIZE)
285281
.cloned()
286282
.expect("default value for cache size");
287-
self.upload_interval = m
288-
.get_one::<u64>(Self::UPLOAD_INTERVAL)
289-
.cloned()
290-
.expect("default value for upload");
291283
self.username = m
292284
.get_one::<String>(Self::USERNAME)
293285
.cloned()
@@ -381,7 +373,6 @@ impl Server {
381373
pub const STAGING: &'static str = "local-staging-path";
382374
pub const CACHE: &'static str = "cache-path";
383375
pub const CACHE_SIZE: &'static str = "cache-size";
384-
pub const UPLOAD_INTERVAL: &'static str = "upload-interval";
385376
pub const USERNAME: &'static str = "username";
386377
pub const PASSWORD: &'static str = "password";
387378
pub const CHECK_UPDATE: &'static str = "check-update";
@@ -467,16 +458,6 @@ impl Server {
467458
.help("Maximum allowed cache size for all streams combined (In human readable format, e.g 1GiB, 2GiB, 100MB)")
468459
.next_line_help(true),
469460
)
470-
.arg(
471-
Arg::new(Self::UPLOAD_INTERVAL)
472-
.long(Self::UPLOAD_INTERVAL)
473-
.env("P_STORAGE_UPLOAD_INTERVAL")
474-
.value_name("SECONDS")
475-
.default_value("60")
476-
.value_parser(validation::upload_interval)
477-
.help("Interval in seconds after which staging data would be sent to the storage")
478-
.next_line_help(true),
479-
)
480461
.arg(
481462
Arg::new(Self::USERNAME)
482463
.long(Self::USERNAME)
@@ -677,7 +658,6 @@ pub mod validation {
677658
use path_clean::PathClean;
678659

679660
use crate::option::MIN_CACHE_SIZE_BYTES;
680-
use crate::storage::LOCAL_SYNC_INTERVAL;
681661
use human_size::{multiples, SpecificSize};
682662

683663
pub fn file_path(s: &str) -> Result<PathBuf, String> {
@@ -755,14 +735,4 @@ pub mod validation {
755735
}
756736
Ok(size)
757737
}
758-
759-
pub fn upload_interval(s: &str) -> Result<u64, String> {
760-
let u = s
761-
.parse::<u64>()
762-
.map_err(|_| "invalid upload interval".to_string())?;
763-
if u < LOCAL_SYNC_INTERVAL {
764-
return Err("object storage upload interval must be 60 seconds or more".to_string());
765-
}
766-
Ok(u)
767-
}
768738
}

server/src/storage/staging.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,12 @@ impl StorageDir {
134134
.ends_with(&hot_filename)
135135
});
136136

137-
//check if arrow files is not empty, fetch the parquet file path from last file from sorted arrow file list
138-
if !(arrow_files.is_empty()) {
139-
arrow_files.sort();
140-
let key = Self::arrow_path_to_parquet(arrow_files.last().unwrap());
141-
for arrow_file_path in arrow_files {
142-
grouped_arrow_file
143-
.entry(key.clone())
144-
.or_default()
145-
.push(arrow_file_path);
146-
}
137+
for arrow_file_path in arrow_files {
138+
let key = Self::arrow_path_to_parquet(&arrow_file_path);
139+
grouped_arrow_file
140+
.entry(key)
141+
.or_default()
142+
.push(arrow_file_path);
147143
}
148144

149145
grouped_arrow_file

0 commit comments

Comments
 (0)