From 46bd20f08c17cb920264e1b14fe372f1b80a799f Mon Sep 17 00:00:00 2001 From: Dimitris Sarlis Date: Mon, 22 Apr 2024 17:33:41 +0000 Subject: [PATCH] fix: [hotfix] move checking heap delta invariant after processing messages in the consensus queue --- rs/execution_environment/src/scheduler.rs | 35 +++++++++++------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/rs/execution_environment/src/scheduler.rs b/rs/execution_environment/src/scheduler.rs index 803db95c19a..158fdc2b794 100644 --- a/rs/execution_environment/src/scheduler.rs +++ b/rs/execution_environment/src/scheduler.rs @@ -1471,24 +1471,6 @@ impl Scheduler for SchedulerImpl { self.purge_expired_ingress_messages(&mut state); } - // See documentation around definition of `heap_delta_estimate` for an - // explanation. - if state.metadata.heap_delta_estimate >= self.config.subnet_heap_delta_capacity { - warn!( - round_log, - "At Round {} @ time {}, current heap delta {} exceeds allowed capacity {}, so not executing any messages.", - current_round, - state.time(), - state.metadata.heap_delta_estimate, - self.config.subnet_heap_delta_capacity - ); - self.finish_round(&mut state, current_round_type); - self.metrics - .round_skipped_due_to_current_heap_delta_above_limit - .inc(); - return state; - } - // Once the subnet messages are executed in threads, each thread will // need its own Csprng instance which is initialized with a distinct // "ExecutionThread". Otherwise, two Csprng instances that are @@ -1578,6 +1560,23 @@ impl Scheduler for SchedulerImpl { } } scheduler_round_limits.update_subnet_round_limits(&subnet_round_limits); + + // See documentation around definition of `heap_delta_estimate` for an explanation. + if state.metadata.heap_delta_estimate >= self.config.subnet_heap_delta_capacity { + warn!( + round_log, + "At Round {} @ time {}, current heap delta {} exceeds allowed capacity {}, so not executing any messages.", + current_round, + state.time(), + state.metadata.heap_delta_estimate, + self.config.subnet_heap_delta_capacity + ); + self.finish_round(&mut state, current_round_type); + self.metrics + .round_skipped_due_to_current_heap_delta_above_limit + .inc(); + return state; + } } // Execute postponed `raw_rand` subnet messages.