Skip to main content

schema

SQLAlchemy ORM for the lock_fences cache table (v1).

Each version package declares its own local Base (its own MetaData) so that multiple versions of the same table can coexist in one process without a __tablename__ collision. Base carries the shared nullable tags column and every ORM in this version inherits it directly.

Adding a column to a new version is an additive migration (see migrations.py): add a nullable mapped_column in the new version's schema and a corresponding upgrade step — never rename/drop/retype in place.

Classes​

Base​

class Base(**kwargs: Any):

Local declarative base for lock_fences v1.

Owns an isolated MetaData (so it never collides with another version of this table) and inherits the shared columns from types/schema.py's Base.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance's class are allowed. These could be, for example, any mapped columns or relationships.

Subclasses​

Variables​

  • static metadata
  • static registry

LockFence​

class LockFence(**kwargs):

SQLAlchemy model for the lock_fences cache table.

One row per keyed lock: the fence that bars every holder but the latest from writing. A Prefect slot whose lease lapses while its holder still runs can be granted to a second holder, so the lock alone does not stop two writers. Each holder takes the fence's next token when it acquires the lock, and a write checks the token is still the latest before it lands, so the older of two holders is refused.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance's class are allowed. These could be, for example, any mapped columns or relationships.

Variables​

  • acquired_at : sqlalchemy.orm.base.Mapped[str | None]
  • fence_key : sqlalchemy.orm.base.Mapped[str]
  • holder_run_id : sqlalchemy.orm.base.Mapped[str | None]
  • tags : sqlalchemy.orm.base.Mapped[dict[str, typing.Any] | None]
  • token : sqlalchemy.orm.base.Mapped[int]