From 6218041b6285d4d7215df086d097ea8fcee93616 Mon Sep 17 00:00:00 2001 From: Erik Darling <2136037+erikdarlingdata@users.noreply.github.com> Date: Tue, 17 Feb 2026 18:33:12 -0500 Subject: [PATCH] Skip offline servers during collection and reduce connection timeout RunDueCollectorsAsync now checks IsOnline status before queuing collectors for each server. Servers marked offline by the connection check are skipped entirely, eliminating wasted timeout cycles. Connection timeout reduced from 15s to 5s to match the connection check timeout. Tested under 30-min HammerDB TPC-C load: 437 Lite collections at 100% success rate, avg 176ms. Zero offline server attempts. Closes #90 Co-Authored-By: Claude Opus 4.6 --- Lite/Services/RemoteCollectorService.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Lite/Services/RemoteCollectorService.cs b/Lite/Services/RemoteCollectorService.cs index fde3d467..ea1e79a2 100644 --- a/Lite/Services/RemoteCollectorService.cs +++ b/Lite/Services/RemoteCollectorService.cs @@ -80,7 +80,7 @@ public partial class RemoteCollectorService /// /// Connection timeout for SQL Server connections in seconds. /// - private const int ConnectionTimeoutSeconds = 15; + private const int ConnectionTimeoutSeconds = 5; /// /// Per-call timing fields set by each collector method. @@ -193,19 +193,28 @@ public async Task RunDueCollectorsAsync(CancellationToken cancellationToken = de return; } - _logger?.LogInformation("Running {CollectorCount} collectors for {ServerCount} servers", - dueCollectors.Count, enabledServers.Count); - var tasks = new List(); + int skippedOffline = 0; foreach (var server in enabledServers) { + var serverStatus = _serverManager.GetConnectionStatus(server.Id); + if (serverStatus.IsOnline == false) + { + skippedOffline++; + _logger?.LogDebug("Skipping offline server '{Server}'", server.DisplayName); + continue; + } + foreach (var collector in dueCollectors) { tasks.Add(RunCollectorAsync(server, collector.Name, cancellationToken)); } } + _logger?.LogInformation("Running {CollectorCount} collectors for {OnlineCount}/{TotalCount} servers ({SkippedCount} offline, skipped)", + dueCollectors.Count, enabledServers.Count - skippedOffline, enabledServers.Count, skippedOffline); + await Task.WhenAll(tasks); }