backend: un-queue zombies left by missing row in v2_job_runtime (#5232)

This commit is contained in:
Lucas Abel
2025-02-06 16:46:32 +01:00
committed by GitHub
parent f81437a5aa
commit 2478df52a5
5 changed files with 32 additions and 8 deletions
@@ -0,0 +1,12 @@
{
"db_name": "PostgreSQL",
"query": "DELETE FROM _sqlx_migrations WHERE version=20250201145632",
"describe": {
"columns": [],
"parameters": {
"Left": []
},
"nullable": []
},
"hash": "67f671d3feb0c7beedd2e99740fec9c0f01b077026c0be08e87b9ba65fde5608"
}
@@ -1,8 +0,0 @@
-- Add up migration script here
-- Migrate `v2_job_queue` moved columns to `v2_job_runtime`:
INSERT INTO v2_job_runtime (id, ping, memory_peak)
SELECT id, __last_ping, __mem_peak
FROM v2_job_queue
-- Locked ones will sync within triggers
FOR UPDATE SKIP LOCKED
ON CONFLICT (id) DO NOTHING;
@@ -0,0 +1,12 @@
-- Add up migration script here
UPDATE v2_job_queue SET
running = false,
started_at = NULL
WHERE running = true AND NOT EXISTS (SELECT 1 FROM v2_job_runtime WHERE id = v2_job_queue.id);
INSERT INTO v2_job_runtime (id, ping, memory_peak)
SELECT id, __last_ping, __mem_peak
FROM v2_job_queue
-- Locked ones will sync within triggers
FOR UPDATE SKIP LOCKED
ON CONFLICT (id) DO NOTHING;
+8
View File
@@ -180,6 +180,14 @@ pub async fn migrate(db: &DB) -> Result<(), Error> {
tracing::info!("Could not remove sqlx migration with version=20250131115248: {err:#}");
}
// Remove the migration `v2_fix_no_runtime` in favor of `v2_fix_no_runtime_2`.
if let Err(err) = sqlx::query!("DELETE FROM _sqlx_migrations WHERE version=20250201145632")
.execute(db)
.await
{
tracing::info!("Could not remove sqlx migration with version=20250201145632: {err:#}");
}
match sqlx::migrate!("../migrations")
.run_direct(&mut custom_migrator)
.await