Skip to content

v0.120.9

@grutt grutt tagged this 17 Nov 20:10
* fix: read allocated resource counts from a per-tenant table

Recomputing the shard aggregation on every lookup is the expensive path.

* fix: serialize allocated resource count writes

Cron and schedule count changes take the workflow's latest version lock
before reading the rows they adjust, and schedule deletes lock the rows
that still count. Workflow delete and invalid-cron delete apply their
deltas. The rebuild holds an exclusive table lock across the delete and
insert. The schedule-fire trigger skips schedules on a deleted workflow.
The migration moves after the ones already on main.

* test: give the late schedule fire its own workflow run

A workflow run can only have one trigger row, so the delete-workflow count test was failing on the second insert.

* fix: move the allocated resource count migration after main

Goose skips a migration whose version is older than ones already applied, so the November 5 timestamp would never run on databases that have moved past it.

* fix: append allocated resource count changes as deltas

Concurrent schedule inserts and fires queued behind each other: each took
an exclusive lock on the workflow's latest version and then updated the
tenant's count row, and the hourly rebuild held an exclusive table lock
across a full scan.

Cron, schedule, and webhook writes now append a row to
tenant_allocated_resource_count_delta in their own transaction. A count is
the tenant's count row plus its deltas, and a ticker job folds the deltas
into the count rows. Schedule writes take a key-share lock on the version,
so they wait only for a version registration or workflow delete. The
unfiltered read appends a correcting delta where the stored count differs
from the live rows, in place of the locked rebuild.

* fix migration

* fix: count a schedule once when its delete waits on a workflow delete

A schedule delete that waited on a workflow delete for the schedule's row
read the version and workflow from before the wait, so both subtracted the
schedule. The version share lock only prevented this when the two saw the
same latest version.

The delete now locks the schedule rows first and reads which of them still
count in a later statement. It takes no version lock, so a fire no longer
waits on a version registration.

* fix: lock only the tenant's own schedules on schedule delete

The ids for a bulk delete come from the request, so the lock taken before counting is now filtered by tenant.
Assets 2
Loading