Skip to content

add JobModel: persistent scheduler job store (#2360, phase 1)#2530

Draft
ebuzerdrmz44 wants to merge 1 commit into
borgbase:masterfrom
ebuzerdrmz44:refactor/scheduler-job-model
Draft

add JobModel: persistent scheduler job store (#2360, phase 1)#2530
ebuzerdrmz44 wants to merge 1 commit into
borgbase:masterfrom
ebuzerdrmz44:refactor/scheduler-job-model

Conversation

@ebuzerdrmz44

Copy link
Copy Markdown
Contributor

Description

First PR of the scheduler refactor (#2360), which I'm splitting into small stacked PRs (full breakdown is on the issue). This one just adds JobModel; nothing reads or writes it yet.

No migration needed. connection.py builds tables with create_tables(), which is safe by default, so the table shows up on both fresh and existing DBs.

The idea: JobModel tracks a job's lifecycle and intent (scheduled, running, done, skipped, interrupted). When a job actually runs it links to the matching EventLogModel row through event_log, so I'm not duplicating start/end/returncode across two tables. EventLogModel stays the record of what executed, and JobModel adds the intent plus the things that never produce a log line, like a job that got skipped.

A few schema questions before I build on it. The rest of the plan doesn't depend on these, but this table's shape does:

  1. Store scheduled jobs as rows, or keep deriving the next run on reload like today? The issue wants pending jobs to survive restarts, but storing them risks a second source of truth against the derivation in set_timer_for_profile. I lean toward persisting skipped and interrupted jobs while leaving next-run derivation as is.
  2. FK or plain strings for profile/repo? EventLogModel uses strings, so its rows survive a profile being deleted. Same for the jobs history, or is a FK fine here?
  3. For crash recovery, is a startup sweep that marks leftover running jobs as interrupted enough, or do you want more than that?

@m3nu If you'd rather this not merge as a bare model, I can fold in the first consumer (skip-reason recording) before then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant