mirror of
https://github.com/okieselbach/AutopilotMonitor.git
synced 2026-10-24 12:42:38 +00:00
fix maintenance logic (separation between timer triggered and manual triggered)
This commit is contained in:
@@ -1 +1 @@
|
||||
502
|
||||
504
|
||||
|
||||
@@ -86,16 +86,11 @@ namespace AutopilotMonitor.Functions.Services
|
||||
await CleanupOldDataAsync();
|
||||
await RecomputePlatformStatsAsync();
|
||||
|
||||
// Safety net: backfill any sessions missing from SessionsIndex
|
||||
await _storageService.BackfillSessionIndexAsync();
|
||||
|
||||
// One-time cleanup: remove ghost SessionsIndex entries caused by the
|
||||
// StoreSessionAsync Replace-mode IndexRowKey bug (now fixed).
|
||||
// TODO: Remove after 2026-06-01
|
||||
await _storageService.CleanupGhostSessionIndexEntriesAsync();
|
||||
|
||||
// Backfill OnboardedAt for tenants that don't have it yet
|
||||
await BackfillTenantOnboardedAtAsync();
|
||||
// Backfill and one-time repair tasks run only via manual trigger (RunManualAsync)
|
||||
// to keep the timer-triggered path lightweight. See RunManualAsync for:
|
||||
// - BackfillSessionIndexAsync (safety net for missing index entries)
|
||||
// - CleanupGhostSessionIndexEntriesAsync (one-time ghost cleanup)
|
||||
// - BackfillTenantOnboardedAtAsync (backfill missing OnboardedAt)
|
||||
|
||||
maintenanceStart.Stop();
|
||||
_logger.LogInformation($"Daily maintenance completed in {maintenanceStart.ElapsedMilliseconds}ms");
|
||||
@@ -132,6 +127,20 @@ namespace AutopilotMonitor.Functions.Services
|
||||
{
|
||||
await CleanupOldDataAsync();
|
||||
result.DataCleanupExecuted = true;
|
||||
|
||||
// --- Backfill & repair tasks (manual-only, not in timer path) ---
|
||||
|
||||
// Safety net: backfill any sessions missing from SessionsIndex
|
||||
await _storageService.BackfillSessionIndexAsync();
|
||||
|
||||
// One-time cleanup: remove ghost SessionsIndex entries caused by the
|
||||
// StoreSessionAsync Replace-mode IndexRowKey bug (now fixed).
|
||||
// TODO: Remove after 2026-06-01
|
||||
await _storageService.CleanupGhostSessionIndexEntriesAsync();
|
||||
|
||||
// Backfill OnboardedAt for tenants that don't have it yet
|
||||
// TODO: Remove once all tenants have been backfilled
|
||||
await BackfillTenantOnboardedAtAsync();
|
||||
}
|
||||
|
||||
await RecomputePlatformStatsAsync();
|
||||
|
||||
+41
-15
@@ -195,22 +195,48 @@ export function MaintenanceSection({
|
||||
</div>
|
||||
<div className="p-6 space-y-4">
|
||||
<p className="text-sm text-purple-900 dark:text-gray-200">
|
||||
Manually trigger the daily maintenance job which includes:
|
||||
Runs all timer-triggered tasks plus additional backfill & repair operations that only run on manual trigger.
|
||||
</p>
|
||||
<ul className="text-sm text-purple-900 dark:text-gray-200 space-y-1 ml-4">
|
||||
<li className="flex items-start">
|
||||
<span className="text-purple-500 dark:text-purple-400 mr-2">•</span>
|
||||
<span>Mark stalled sessions as timed out</span>
|
||||
</li>
|
||||
<li className="flex items-start">
|
||||
<span className="text-purple-500 dark:text-purple-400 mr-2">•</span>
|
||||
<span>Aggregate metrics into historical snapshots (with automatic catch-up for missed days)</span>
|
||||
</li>
|
||||
<li className="flex items-start">
|
||||
<span className="text-purple-500 dark:text-purple-400 mr-2">•</span>
|
||||
<span>Clean up old data based on retention policies</span>
|
||||
</li>
|
||||
</ul>
|
||||
<div className="space-y-3">
|
||||
<div>
|
||||
<p className="text-xs font-semibold text-purple-700 dark:text-purple-300 uppercase tracking-wide mb-1">Standard tasks (also run by 2h timer)</p>
|
||||
<ul className="text-sm text-purple-900 dark:text-gray-200 space-y-1 ml-4">
|
||||
<li className="flex items-start">
|
||||
<span className="text-purple-500 dark:text-purple-400 mr-2">•</span>
|
||||
<span>Mark stalled sessions as timed out</span>
|
||||
</li>
|
||||
<li className="flex items-start">
|
||||
<span className="text-purple-500 dark:text-purple-400 mr-2">•</span>
|
||||
<span>Aggregate metrics into historical snapshots</span>
|
||||
</li>
|
||||
<li className="flex items-start">
|
||||
<span className="text-purple-500 dark:text-purple-400 mr-2">•</span>
|
||||
<span>Clean up old data based on retention policies</span>
|
||||
</li>
|
||||
<li className="flex items-start">
|
||||
<span className="text-purple-500 dark:text-purple-400 mr-2">•</span>
|
||||
<span>Recompute platform-wide statistics</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-xs font-semibold text-amber-700 dark:text-amber-300 uppercase tracking-wide mb-1">Manual-only tasks (backfill & repair)</p>
|
||||
<ul className="text-sm text-purple-900 dark:text-gray-200 space-y-1 ml-4">
|
||||
<li className="flex items-start">
|
||||
<span className="text-amber-500 dark:text-amber-400 mr-2">•</span>
|
||||
<span>Backfill sessions missing from SessionsIndex</span>
|
||||
</li>
|
||||
<li className="flex items-start">
|
||||
<span className="text-amber-500 dark:text-amber-400 mr-2">•</span>
|
||||
<span>Clean up ghost SessionsIndex entries <span className="text-xs text-gray-500 dark:text-gray-400">(remove after 2026-06)</span></span>
|
||||
</li>
|
||||
<li className="flex items-start">
|
||||
<span className="text-amber-500 dark:text-amber-400 mr-2">•</span>
|
||||
<span>Backfill tenant OnboardedAt dates <span className="text-xs text-gray-500 dark:text-gray-400">(remove when complete)</span></span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div className="bg-purple-50 dark:bg-gray-700 border border-purple-200 dark:border-purple-600 rounded-lg p-4">
|
||||
<label className="block text-sm font-medium text-purple-800 dark:text-purple-200 mb-1">
|
||||
Target Date (optional)
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user