Implement authorized live event replay
This commit is contained in:
parent
4c93c25692
commit
06a7ac56b7
3 changed files with 2370 additions and 364 deletions
|
|
@ -342,6 +342,9 @@ impl AttemptService {
|
|||
json!({ "job_id": authority.job_id }),
|
||||
)
|
||||
.await?;
|
||||
if retry {
|
||||
enqueue(tx, "job.updated", json!({ "job_id": authority.job_id })).await?;
|
||||
}
|
||||
accepted_phase(if retry {
|
||||
JobPhase::RetryWait
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -668,6 +668,8 @@ impl AttemptService {
|
|||
.retry_not_before
|
||||
.is_some_and(|due| due <= OffsetDateTime::now_utc())
|
||||
{
|
||||
let mut tx = self.pool.begin().await?;
|
||||
let now = OffsetDateTime::now_utc();
|
||||
let changed = sqlx::query(
|
||||
"UPDATE jobs SET phase = 'queued', dispatch_needed = TRUE,
|
||||
retry_not_before = NULL, revision = revision + 1, updated_at = $2
|
||||
|
|
@ -675,14 +677,16 @@ impl AttemptService {
|
|||
AND retry_not_before <= $2",
|
||||
)
|
||||
.bind(job_id.as_str())
|
||||
.bind(OffsetDateTime::now_utc())
|
||||
.execute(&self.pool)
|
||||
.bind(now)
|
||||
.execute(tx.as_mut())
|
||||
.await?;
|
||||
if changed.rows_affected() == 1 {
|
||||
enqueue(&mut tx, "job.updated", json!({ "job_id": job_id })).await?;
|
||||
report.retries_scheduled += 1;
|
||||
row.phase = "queued".into();
|
||||
row.dispatch_needed = true;
|
||||
}
|
||||
tx.commit().await?;
|
||||
}
|
||||
}
|
||||
if row.phase == "queued"
|
||||
|
|
@ -1222,6 +1226,7 @@ async fn reap_lost_attempt(
|
|||
.execute(tx.as_mut())
|
||||
.await?;
|
||||
enqueue(tx, "job.retry_wait", json!({ "job_id": job_id })).await?;
|
||||
enqueue(tx, "job.updated", json!({ "job_id": job_id })).await?;
|
||||
} else {
|
||||
sqlx::query(
|
||||
"UPDATE jobs SET phase = 'failed', authority_attempt_id = NULL,
|
||||
|
|
|
|||
|
|
@ -501,6 +501,7 @@ impl AttemptService {
|
|||
));
|
||||
}
|
||||
enqueue(tx, "job.dispatch", json!({ "job_id": job_id })).await?;
|
||||
enqueue(tx, "job.updated", json!({ "job_id": job_id })).await?;
|
||||
Ok(RecoveryOutcome::Reaped)
|
||||
})
|
||||
})
|
||||
|
|
@ -816,6 +817,7 @@ async fn authorize_attempt(
|
|||
.bind(checkpoint_owner_after_claim)
|
||||
.execute(tx.as_mut())
|
||||
.await?;
|
||||
enqueue(tx, "job.updated", json!({ "job_id": input.job_id })).await?;
|
||||
Ok(ClaimOutcome::Claimed {
|
||||
authority: AttemptAuthority {
|
||||
job_id: input.job_id.clone(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue