Add periodic route data cleanup to epoch operations
Implements automatic cleanup of route monitoring results to prevent unbounded storage growth while maintaining data for performance analysis. - Add purge_old_routes() method to StorageManager following existing patterns - Integrate route cleanup into purge_old_statuses() wrapper function - Route data now purged every epoch with 48-hour retention, to facilitate comparisons with legacy data - Update logging to reflect cleanup of both node statuses and routes
This commit is contained in:
Generated
+2
-2
@@ -4731,7 +4731,7 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3"
|
||||
|
||||
[[package]]
|
||||
name = "nym-api"
|
||||
version = "1.1.57"
|
||||
version = "1.1.61"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@@ -6038,7 +6038,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nym-network-monitor"
|
||||
version = "1.1.0"
|
||||
version = "1.1.4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"axum 0.7.9",
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
[package]
|
||||
name = "nym-api"
|
||||
license = "GPL-3.0"
|
||||
version = "1.1.60"
|
||||
version = "1.1.61"
|
||||
authors.workspace = true
|
||||
edition = "2021"
|
||||
rust-version.workspace = true
|
||||
|
||||
@@ -195,7 +195,7 @@ impl EpochAdvancer {
|
||||
self.update_rewarded_set_and_advance_epoch(&nym_nodes)
|
||||
.await?;
|
||||
|
||||
info!("Purging old node statuses from the storage...");
|
||||
info!("Purging old data (node statuses and routes) from the storage...");
|
||||
let cutoff = (epoch_end - 2 * ONE_DAY).unix_timestamp();
|
||||
self.storage.purge_old_statuses(cutoff).await?;
|
||||
|
||||
|
||||
@@ -1198,6 +1198,22 @@ impl StorageManager {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Removes all route monitoring results that are older than the
|
||||
/// provided timestamp. This method is indirectly called at every reward cycle.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `timestamp`: timestamp specifying the purge cutoff.
|
||||
pub(super) async fn purge_old_routes(
|
||||
&self,
|
||||
timestamp: i64,
|
||||
) -> Result<(), sqlx::Error> {
|
||||
sqlx::query!("DELETE FROM routes WHERE timestamp < ?", timestamp)
|
||||
.execute(&self.connection_pool)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Returns public key, owner and id of all mixnodes that have had any statuses submitted
|
||||
/// within the provided time interval.
|
||||
///
|
||||
|
||||
@@ -943,8 +943,9 @@ impl NymApiStorage {
|
||||
/// * `until`: timestamp specifying the purge cutoff.
|
||||
pub(crate) async fn purge_old_statuses(&self, until: i64) -> Result<(), NymApiStorageError> {
|
||||
self.manager.purge_old_mixnode_statuses(until).await?;
|
||||
self.manager.purge_old_gateway_statuses(until).await?;
|
||||
self.manager
|
||||
.purge_old_gateway_statuses(until)
|
||||
.purge_old_routes(until)
|
||||
.await
|
||||
.map_err(|err| err.into())
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "nym-network-monitor"
|
||||
version = "1.1.3"
|
||||
version = "1.1.4"
|
||||
authors.workspace = true
|
||||
repository.workspace = true
|
||||
homepage.workspace = true
|
||||
|
||||
@@ -175,7 +175,11 @@ async fn nym_topology_forced_all_from_env() -> anyhow::Result<NymTopology> {
|
||||
let node_ids = topology
|
||||
.node_details()
|
||||
.iter()
|
||||
.filter(|(_node_id, node)| node.supported_roles.mixnode)
|
||||
.filter(|(_node_id, node)| {
|
||||
node.supported_roles.mixnode
|
||||
&& !node.supported_roles.mixnet_entry
|
||||
&& !node.supported_roles.mixnet_exit
|
||||
})
|
||||
.map(|(node_id, _)| *node_id)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user