Skip to content

Commit

Permalink
maintenance: fix systemd schedule overlaps
Browse files Browse the repository at this point in the history
The 'git maintenance run' command prevents concurrent runs in the same
repository using a 'maintenance.lock' file. However, when using systemd
the hourly maintenance runs the same time as the daily and weekly runs.
(Similarly, daily maintenance runs at the same time as weekly
maintenance.) These competing commands result in some maintenance not
actually being run.

This overlap was something we could not fix until we made the recent
change to not use the builting 'hourly', 'daily', and 'weekly' schedules
in systemd. We can adjust the schedules such that:

 1. Hourly runs avoid the 0th hour.
 2. Daily runs avoid Monday.

This will keep maintenance runs from colliding when using systemd.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
  • Loading branch information
derrickstolee committed Aug 9, 2023
1 parent 233d2b3 commit 66fb522
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions builtin/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2318,11 +2318,11 @@ static int systemd_timer_write_unit_file(enum schedule_priority schedule,

switch (schedule) {
case SCHEDULE_HOURLY:
schedule_pattern = xstrfmt("*-*-* *:%02d:00", minute);
schedule_pattern = xstrfmt("*-*-* 1..23:%02d:00", minute);
break;

case SCHEDULE_DAILY:
schedule_pattern = xstrfmt("*-*-* 0:%02d:00", minute);
schedule_pattern = xstrfmt("Tue..Sun *-*-* 0:%02d:00", minute);
break;

case SCHEDULE_WEEKLY:
Expand Down

0 comments on commit 66fb522

Please sign in to comment.