CanonicalZoneIdAllocator
final class CanonicalZoneIdAllocator (View source)
Settles the canonical id of zone rows this application creates in API backend mode.
A new row keeps its own row id as canonical id unless another row, a group assignment or an API key scope already uses that number as a zone id. Then the row itself moves to an id above all of them, so it never takes over (or inherits the grants of) another zone's id, and rows created after it get their own ids again. Build one per transaction before inserting: the backend marker row is locked first, so concurrent creators queue up, and the zones rows are then read with a lock.
Constants
| private PGSQL_LOCK_KEY |
Advisory lock key for zone id allocation on PostgreSQL (the issue that introduced it). |
Methods
Give the row just inserted under $rowId its canonical id and return it; the row's id changes to that value too when its own id was taken.
Details
__construct(PDO $db)
No description
int
settle(int $rowId)
Give the row just inserted under $rowId its canonical id and return it; the row's id changes to that value too when its own id was taken.