diff --git a/db/workflow.go b/db/workflow.go index 5f9d0bee2..b56f39834 100644 --- a/db/workflow.go +++ b/db/workflow.go @@ -33,7 +33,7 @@ var ( // CreateWorkflow creates a new workflow func (d TinkDB) CreateWorkflow(ctx context.Context, wf Workflow, data string, id uuid.UUID) error { - tx, err := d.instance.BeginTx(ctx, &sql.TxOptions{Isolation: sql.LevelRepeatableRead}) + tx, err := d.instance.BeginTx(ctx, &sql.TxOptions{Isolation: sql.LevelSerializable}) if err != nil { return errors.Wrap(err, "BEGIN transaction") } diff --git a/deploy/db/tinkerbell-init.sql b/deploy/db/tinkerbell-init.sql index f78bd3835..a0eda5203 100644 --- a/deploy/db/tinkerbell-init.sql +++ b/deploy/db/tinkerbell-init.sql @@ -68,6 +68,8 @@ CREATE TABLE IF NOT EXISTS workflow_worker_map ( , worker_id UUID NOT NULL ); +CREATE UNIQUE INDEX IF NOT EXISTS uidx_workflow_worker_map ON workflow_worker_map (workflow_id, worker_id); + CREATE TABLE IF NOT EXISTS workflow_data ( workflow_id UUID NOT NULL , version INT