diff --git a/AsbCloudInfrastructure/Services/SAUB/TelemetryDataCache.cs b/AsbCloudInfrastructure/Services/SAUB/TelemetryDataCache.cs index c99b6c95..8d74d478 100644 --- a/AsbCloudInfrastructure/Services/SAUB/TelemetryDataCache.cs +++ b/AsbCloudInfrastructure/Services/SAUB/TelemetryDataCache.cs @@ -157,9 +157,12 @@ namespace AsbCloudInfrastructure.Services.SAUB throw new Exception("Multiple cache loading detected."); isLoading = true; - Well[] wells = Array.Empty(); - wells = await db.Set() + var defaultTimeout = db.Database.GetCommandTimeout(); + System.Diagnostics.Trace.TraceInformation($"cache loading starting. Setting CommandTimeout 90s ({defaultTimeout})"); + db.Database.SetCommandTimeout(TimeSpan.FromSeconds(90)); + + Well[] wells = await db.Set() .Include(well => well.Telemetry) .Include(well => well.Cluster) .Where(well => well.IdTelemetry != null) @@ -188,6 +191,7 @@ namespace AsbCloudInfrastructure.Services.SAUB System.Diagnostics.Trace.TraceInformation($"cache<{typeof(TDto).Name}> load complete"); isLoading = false; + db.Database.SetCommandTimeout(defaultTimeout); } private static async Task GetOrDefaultCacheDataFromDbAsync(IAsbCloudDbContext db, int idTelemetry, int capacity, double hoursOffset, CancellationToken token)