feat(recov. job): add drive consistency service
This commit is contained in:
@@ -462,12 +462,23 @@ impl PgJobStoreProvider {
|
||||
// second INSERT; on conflict we retry.
|
||||
let run_id = Uuid::new_v4();
|
||||
let now = Utc::now();
|
||||
// ON CONFLICT here infers the partial unique index by
|
||||
// matching `(job_name)` + the WHERE predicate that
|
||||
// matches `one_active_run_per_job`. We cannot use
|
||||
// `ON CONFLICT ON CONSTRAINT one_active_run_per_job`
|
||||
// because `CREATE UNIQUE INDEX` produces an index, not
|
||||
// a named constraint from PG's perspective; that
|
||||
// syntax is reserved for `ALTER TABLE ... ADD CONSTRAINT
|
||||
// UNIQUE`. Inference form is equivalent and works with
|
||||
// partial indexes.
|
||||
let result = sqlx::query(
|
||||
r#"
|
||||
INSERT INTO jobs.recoverable_runs
|
||||
(id, job_name, status, started_at, last_progress_at)
|
||||
VALUES ($1, $2, 'Running', $3, $3)
|
||||
ON CONFLICT ON CONSTRAINT one_active_run_per_job DO NOTHING
|
||||
ON CONFLICT (job_name)
|
||||
WHERE status IN ('Running', 'Paused', 'CancelRequested')
|
||||
DO NOTHING
|
||||
"#,
|
||||
)
|
||||
.bind(run_id)
|
||||
|
||||
@@ -25,9 +25,19 @@ use serde::{Deserialize, Serialize};
|
||||
/// - `dedup_gc` — skip the orphan grace window (grace = 0).
|
||||
/// - `grant_cleanup` — grace = 0.
|
||||
/// - Others (trash_cleanup, storage_reconcile, …) — ignored.
|
||||
///
|
||||
/// Semantics of `deep`, per job:
|
||||
/// - `consistency_batch` — propagate to sub-jobs; only `storage_consistency`
|
||||
/// currently respects it. Wraps the "run all consistency checks
|
||||
/// including the slow ones" case behind the same job_name lock as
|
||||
/// the normal batch (Ed's Option B, 2026-07-29).
|
||||
/// - `storage_consistency` (future) — enables per-blob re-BLAKE3 (bitrot
|
||||
/// detection) + mime sniff alongside the fast orphan check.
|
||||
/// - Others — ignored.
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct JobRunArgs {
|
||||
pub force: bool,
|
||||
pub deep: bool,
|
||||
}
|
||||
|
||||
/// Uniform outcome the supervisor logs and stores for every job dispatch.
|
||||
|
||||
Reference in New Issue
Block a user