Pending backups can preempt a backup that is already executing Backup scheduling must…
- User
Pending backups can preempt a backup that is already executing
Backup scheduling must not select a pending backup while another backup is already executing. When none is executing, select the oldest pending backup, using a deterministic tie-break for equal creation times.
Interface
Type: Function Name: IsExecuting Path: api/v1/backup_funcs.go Input: () Output: bool Description: Returns true if the backup has started or is running. Use this to determine whether a backup holds active resources and should not be preempted.
- Assistant
The build hit a fork resource limit; retrying with limited parallelism:
- Assistant
Build and vet pass. Now run the unit tests for the affected packages:
- Assistant
Tests pass; gofmt wants reformatting (the doc-comment list). Fix and re-check:
- Assistant
Now run the controller test package and add regression tests for the new behavior. First look at the existing test structure:
- Assistant
All checks pass. Summary of the fix:
Bug
In
CanExecuteBackup(api/v1/backup_funcs.go), the scheduling loop usedIsInProgress(), which treatspendingthe same asstarted/running. Since the list is sorted by name, a pending backup whose name sorted before an actually executing backup was granted execution — preempting a backup that already held active resources (WAL archiving session, snapshot in flight, etc.).Changes —
api/v1/backup_funcs.go-
New
IsExecuting()method on*Backup(api/v1/backup_funcs.go:148): returns true only forBackupPhaseStartedorBackupPhaseRunning— the phases where the backup holds active resources. -
CanExecuteBackuprewritten (api/v1/backup_funcs.go:178):- If any backup is executing, only that backup may proceed — pending backups can never preempt it. (With multiple executing backups from a race, the first in alphabetical order wins, preserving the existing tie-breaker.)
- When none is executing, the oldest pending backup by creation time is selected, with the name-sorted list providing a deterministic tie-break for equal creation times (strict
Beforecomparison keeps the alphabetically-first item).
-
GetPendingBackupNamesnow usesIsExecuting(), so backups explicitly in thependingphase are correctly reported as pending (previously they vanished from the list becauseIsInProgress()excluded them).
Tests
- Added
IsExecuting()assertions across all phases (including the previously untestedstarted) inapi/v1/backup_funcs_test.go. - Added regression cases: an older, alphabetically-first pending backup does not preempt a running one; and with no executing backup, the oldest pending backup is chosen even when its name sorts last.
go test ./api/v1/andgo test ./internal/controller/pass;go vetandgofmtclean.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- fable-5Compare side by side →
- fable-5Compare side by side →