mirror of
https://github.com/penpot/penpot.git
synced 2025-06-27 15:08:18 +02:00
♻️ Refactor task worker.
This commit is contained in:
parent
bda9cad3c2
commit
b1b3ad61a5
13 changed files with 317 additions and 131 deletions
29
backend/resources/migrations/0015-improve-tasks-tables.sql
Normal file
29
backend/resources/migrations/0015-improve-tasks-tables.sql
Normal file
|
@ -0,0 +1,29 @@
|
|||
DROP TABLE task;
|
||||
|
||||
CREATE TABLE task (
|
||||
id uuid DEFAULT uuid_generate_v4(),
|
||||
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
|
||||
modified_at timestamptz NOT NULL DEFAULT clock_timestamp(),
|
||||
completed_at timestamptz NULL DEFAULT NULL,
|
||||
scheduled_at timestamptz NOT NULL,
|
||||
priority smallint DEFAULT 100,
|
||||
|
||||
queue text NOT NULL,
|
||||
|
||||
name text NOT NULL,
|
||||
props jsonb NOT NULL,
|
||||
|
||||
error text NULL DEFAULT NULL,
|
||||
retry_num smallint NOT NULL DEFAULT 0,
|
||||
max_retries smallint NOT NULL DEFAULT 3,
|
||||
status text NOT NULL DEFAULT 'new',
|
||||
|
||||
PRIMARY KEY (id, status)
|
||||
) PARTITION BY list(status);
|
||||
|
||||
CREATE TABLE task_completed partition OF task FOR VALUES IN ('completed', 'failed');
|
||||
CREATE TABLE task_default partition OF task default;
|
||||
|
||||
CREATE INDEX task__scheduled_at__queue__idx
|
||||
ON task (scheduled_at, queue)
|
||||
WHERE status = 'new' or status = 'retry';
|
Loading…
Add table
Add a link
Reference in a new issue