Skip to content

Commit b77658a

Browse files
committed
add migration and checks for distributed
1 parent 4d1b95c commit b77658a

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

server/src/handlers/http/modal/ingest_server.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use crate::storage::object_storage::ingestor_metadata_path;
3333
use crate::storage::object_storage::parseable_json_path;
3434
use crate::storage::staging;
3535
use crate::storage::ObjectStorageError;
36+
use crate::storage::StorageMetadata;
3637
use crate::sync;
3738

3839
use super::server::Server;
@@ -276,7 +277,24 @@ impl IngestServer {
276277
let path = parseable_json_path();
277278

278279
match store.get_object(&path).await {
279-
Ok(_) => Ok(()),
280+
Ok(bytes) => {
281+
let size = serde_json::from_slice::<StorageMetadata>(&bytes)?.hot_tier_capacity;
282+
let hot_tier_enabled = CONFIG.is_hot_tier_active();
283+
match size {
284+
Some(size) => {
285+
if hot_tier_enabled && CONFIG.parseable.local_cache_size != size {
286+
return Err(ObjectStorageError::Custom("Hot Tier Capacity does not match with Other Nodes. Please check the hot tier capacity and try again."));
287+
}
288+
}
289+
None => {
290+
if hot_tier_enabled {
291+
return Err(ObjectStorageError::Custom("Hot Tier is active on Current Node but disabled on Other Nodes. Please set hot tier and try again."));
292+
}
293+
}
294+
}
295+
// fall through
296+
Ok(())
297+
}
280298
Err(_) => Err(ObjectStorageError::Custom(
281299
"Query Server has not been started yet. Please start the querier server first."
282300
,

server/src/migration/metadata_migration.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ pub fn update_v3(mut storage_metadata: JsonValue) -> JsonValue {
121121
);
122122
}
123123

124+
let hot_tier_capacity = metadata.get("hot_tier_capacity");
125+
if hot_tier_capacity.is_none() {
126+
metadata.insert(
127+
"hot_tier_capacity".to_string(),
128+
JsonValue::Bool(CONFIG.is_hot_tier_active()),
129+
);
130+
}
131+
124132
storage_metadata
125133
}
126134

server/src/storage/store_metadata.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,17 @@ pub struct StorageMetadata {
6161
pub roles: HashMap<String, Vec<DefaultPrivilege>>,
6262
#[serde(default)]
6363
pub default_role: Option<String>,
64+
pub hot_tier_capacity: Option<u64>,
6465
}
6566

6667
impl StorageMetadata {
6768
pub fn new() -> Self {
69+
let hot_tier_capacity = if CONFIG.is_hot_tier_active() {
70+
Some(CONFIG.parseable.local_cache_size)
71+
} else {
72+
None
73+
};
74+
6875
Self {
6976
version: "v3".to_string(),
7077
mode: CONFIG.storage_name.to_owned(),
@@ -76,6 +83,7 @@ impl StorageMetadata {
7683
streams: Vec::new(),
7784
roles: HashMap::default(),
7885
default_role: None,
86+
hot_tier_capacity,
7987
}
8088
}
8189

0 commit comments

Comments
 (0)