fix: logging never fails a job, one backup retention, first copy after the upgrade
Owner review 2, phase 2 review findings (scheduler core). - Log.Write caught only IOException. Microsoft.Extensions.Logging wraps provider failures in an AggregateException, so a log line that could not be written (in tests: the process-wide sink of a stopped server whose log folder was gone) escaped JobEngine.RunAsync's catch before the failure was stored: the job stayed running and the worker faulted. This was the cause of the intermittent JobApiTests/ArchiveModuleTests failures. Log.Write now drops any non-fatal sink failure, TeeLogSink keeps a line from the other sinks, FileLogSink drops a line it cannot write and reopens the file at the next one, and LoggerSink drops what the providers throw. The scheduler's loop relies on the same guarantee. - The daily backup loop (RunDailyAsync, IsDue, Interval, CheckInterval) had no caller since the index-backup schedule replaced it; it is removed and the DatabaseBackups summary describes the schedule. - The first copy after the upgrade no longer waits a day (or for 03:00): SystemSchedule.LastDone seeds a new row due at once when its work was last done a period or more before, and both hosts pass the newest copy in the backups folder for index-backup. - Back up now (Settings and Archive), the copy kept before a restore and a backup job that keeps fewer prune to the largest Copies kept of the backup schedules (DatabaseBackups.KeptAsync), not a fixed three. The four tooltips that promised three daily copies are reworded (en, it) and their stale translations deleted. - New tests for the scheduler loop itself: a tick, Wake, a pass that threw, and dispose during a pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit c5ad0c4c3f636129afe5dd1ce039185516da5621)
This commit is contained in:
1 parent
422f33d5f3
commit
e384564784
59 files changed
+668
-264
No files matched your search
@@ -52,8 +52,16 @@ public sealed class LoggerSink(ILoggerFactory factory) : ILogSink
|
||||
CoreLogLevel.Warning => MsLogLevel.Warning,
|
||||
_ => MsLogLevel.Error,
|
||||
};
|
||||
try
|
||||
{
|
||||
#pragma warning disable CA2254 // Engine messages are preformatted.
|
||||
logger.Log(ms, exception, message);
|
||||
logger.Log(ms, exception, message);
|
||||
#pragma warning restore CA2254
|
||||
}
|
||||
catch (AggregateException)
|
||||
{
|
||||
// A provider could not write it (Microsoft.Extensions.Logging gathers what they throw): the line is dropped, as
|
||||
// Log.Write would drop it, so the engine code that logs goes on.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public sealed class ServerScheduleHost : IScheduleHost
|
||||
{
|
||||
public const string ArchiveScan = "archive-scan";
|
||||
public const string UploadCleanup = "upload-cleanup";
|
||||
public const string IndexBackup = "index-backup";
|
||||
public const string IndexBackup = DatabaseBackups.ScheduleKey;
|
||||
public const string Housekeeping = "housekeeping";
|
||||
public const string AuditCleanup = "audit-cleanup";
|
||||
|
||||
@@ -73,11 +73,12 @@ public sealed class ServerScheduleHost : IScheduleHost
|
||||
new(UploadCleanup, "Upload clean-up", ScheduleActions.Cleanup, ScheduleRecurrence.Interval(UploadSweepHours, RecurrenceUnit.Hours),
|
||||
new ScheduleParametersDto(OlderThanDays: UploadMaintenance.FinishedRetentionDays, Steps: [UploadCleanupStep.StepName])),
|
||||
};
|
||||
// PostgreSQL is backed up with its own tools (BRIEF §6.2): no schedule that could never run.
|
||||
// PostgreSQL is backed up with its own tools (BRIEF §6.2): no schedule that could never run. Seeded due at once
|
||||
// when the newest copy is a day old, as the daily loop it replaced made one at start.
|
||||
if (DatabaseBackups.Unavailable(_db) is null)
|
||||
{
|
||||
list.Add(new(IndexBackup, "Index backup", ScheduleActions.Backup, ScheduleRecurrence.DailyAt(nightly.Backup),
|
||||
new ScheduleParametersDto(Keep: DatabaseBackups.Keep)));
|
||||
new ScheduleParametersDto(Keep: DatabaseBackups.Keep), LastDone: DatabaseBackups.Newest(_db, _archives?.BackupDirectory)));
|
||||
}
|
||||
list.Add(new(Housekeeping, "Housekeeping", ScheduleActions.Cleanup, ScheduleRecurrence.DailyAt(nightly.History),
|
||||
new ScheduleParametersDto(OlderThanDays: _options.JobHistoryDays, Steps: [Chronos.Data.Housekeeping.CleanupSteps.JobHistory])));
|
||||
|
||||
Reference in new issue
Block a user