Skip to content
This repository was archived by the owner on Jan 27, 2026. It is now read-only.

Commit 6481c56

Browse files
authored
improve node metrics migration (#553)
1 parent a45c2eb commit 6481c56

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

crates/orchestrator/src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,12 @@ async fn main() -> Result<()> {
224224
// Run one-time migration for inactive nodes
225225
let migration_store_context = store_context.clone();
226226
if matches!(server_mode, ServerMode::ProcessorOnly | ServerMode::Full) {
227-
run_inactive_node_metric_migration(migration_store_context).await?;
227+
let migration_store_context = migration_store_context.clone();
228+
tokio::spawn(async move {
229+
if let Err(e) = run_inactive_node_metric_migration(migration_store_context).await {
230+
error!("Failed to run inactive node metric migration: {}", e);
231+
}
232+
});
228233
}
229234

230235
let p2p_client = Arc::new(P2PClient::new(wallet.clone()).await.unwrap());

crates/orchestrator/src/store/domains/metrics_store.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::store::core::RedisStore;
22
use alloy::primitives::Address;
33
use anyhow::{anyhow, Result};
4-
use log::error;
4+
use log::{error, info};
55
use redis::AsyncCommands;
66
use shared::models::metric::MetricEntry;
77
use std::collections::HashMap;
@@ -30,6 +30,7 @@ impl MetricsStore {
3030
// Check if the new node-centric key already exists
3131
let exists: bool = con.exists(&new_key).await?;
3232
if exists {
33+
info!("Migration already complete for this node: {}", node_address);
3334
// Migration already complete for this node
3435
return Ok(());
3536
}
@@ -83,12 +84,13 @@ impl MetricsStore {
8384
}
8485

8586
pipe.query_async::<()>(&mut con).await?;
86-
} else {
87-
// Even if no metrics exist, create an empty key to mark migration as complete
88-
let _: () = con.hset(&new_key, "_migrated", "true").await?;
89-
let _: () = con.hdel(&new_key, "_migrated").await?;
9087
}
9188

89+
// Always create the key to mark migration as complete, even if no metrics exist
90+
// This prevents future migration attempts for nodes without data
91+
let _: () = con.hset(&new_key, "_migrated", "true").await?;
92+
let _: () = con.hdel(&new_key, "_migrated").await?;
93+
9294
Ok(())
9395
}
9496

0 commit comments

Comments
 (0)