From 242a33363161579ee00ca5346b913c36d154ad5c Mon Sep 17 00:00:00 2001 From: tievolu <78606440+tievolu@users.noreply.github.com> Date: Fri, 21 Jul 2023 16:35:54 +0100 Subject: [PATCH] Increase value of $max_recent_bandwidth_usages After running fine for 90 days the script suddenly died because it couldn't find a record of the bandwidth usage for a particular time slot: Fri Jul 21 15:47:36.167 2023 [6150-0015312751]: FATAL ERROR: Failed to get upload bandwidth at 15:47:13.287. Earliest of 45 (max 45) bandwidth samples' start time = 15:47:13.464 It seems that in some strange and rare circumstances the number I calculate for $max_recent_bandwidth_usages is not sufficient. This is going to be very tricky to debug if it only happens once every three months, so this patch just artificially increases $max_recent_bandwidth_usages slightly so we should be covered. I was actually already bumping it slightly, but evidently that arbitrary bump of 2 wasn't enough, so I've increased it to 10. As mentioned in the code there should be zero performance impact - just a *tiny* increase in memory usage. --- sqm-autorate.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sqm-autorate.pl b/sqm-autorate.pl index a5c935a..badf5eb 100644 --- a/sqm-autorate.pl +++ b/sqm-autorate.pl @@ -351,8 +351,8 @@ # couple of extra samples does not impact performance because we always search backwards # starting with the most recent sample. Redundant samples at the end of the array have # no impact beyond a *tiny* increase in memory usage. -my $max_for_adaptive_idle_delay = $icmp_adaptive ? &round_up($icmp_adaptive_idle_delay / $latency_check_interval) + 2 : 0; -my $max_for_icmp_results = &round_up( (((max($icmp_interval_loaded, $icmp_interval_idle, 1) * $max_recent_results) + $icmp_timeout) / $latency_check_interval) ) + 2; +my $max_for_adaptive_idle_delay = $icmp_adaptive ? &round_up($icmp_adaptive_idle_delay / $latency_check_interval) + 10 : 0; +my $max_for_icmp_results = &round_up( (((max($icmp_interval_loaded, $icmp_interval_idle, 1) * $max_recent_results) + $icmp_timeout) / $latency_check_interval) ) + 10; my $max_recent_bandwidth_usages = max($max_for_icmp_results, $max_for_adaptive_idle_delay); # Create an array to store the recent bandwidth usage statistics, and initialise it