Files
windmill/backend/migrations/20260405160440_background_task_state.up.sql
Ruben Fiszel f703fba1ef fix: log cleanup scans S3 orphans and works cross-server (#8729)
* fix: log cleanup scans S3 orphans and works cross-server

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: don't skip service log orphan scan when job retention is disabled

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: time-based heartbeat + flag partial folder sizes on list errors

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor: move background_task module from common to api-settings

Only log_cleanup and storage_usage use it today, both in windmill-api-settings.
Keeping it in the consumer crate narrows the blast radius; if workers or
indexer later need cross-server lease+progress coordination they can move it
back to common then.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-05 16:56:46 +00:00

20 lines
894 B
SQL

-- Tracks the live state of long-running background tasks coordinated across
-- multiple server replicas (log cleanup, object-storage usage scan, staggered
-- graceful restart). Previously these were stored in-memory per-process or in
-- `global_settings` (which is conceptually for user-configurable instance
-- settings and is exposed via the settings UI / export).
--
-- `value` holds task-specific JSON. `running`/`owner`/`updated_at` implement
-- a lease: a task is "free" if running=false OR updated_at is older than the
-- heartbeat-stale threshold (handled in application code, see
-- windmill-common/src/background_task.rs).
CREATE TABLE background_task_state (
name TEXT PRIMARY KEY,
value JSONB NOT NULL,
running BOOLEAN NOT NULL DEFAULT FALSE,
owner TEXT,
started_at TIMESTAMPTZ,
finished_at TIMESTAMPTZ,
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);