Skip to content

feat: a plan says what it will lock, on paper as well as in memory - #41

Closed
AlexeyShalaev wants to merge 1 commit into
feat/cli-metricsfrom
feat/plan-locks
Closed

AlexeyShalaev wants to merge 1 commit into
feat/cli-metricsfrom
feat/plan-locks

Conversation

@AlexeyShalaev

Copy link
Copy Markdown
Member

The answer to "plan --sql" from the status comment, after measuring what it would cost.

What is here. Every operation carried capabilities — the heaviest lock it takes and on what, and whether it can run inside a transaction block — as a property, so the plan a file held had lost the one thing a DBA reads before agreeing to a window. capabilities and is_destructive are now computed_fields: serialized on the way out, ignored on the way in, so the round trip holds (tested) and a saved plan is reviewable for its locks without the CLI. plan --locks prints the same for a person, with the operations that cannot run inside a transaction block marked — they are the ones a crash leaves half-done.

The subclass overrides keep working under a base-class computed_field: pydantic resolves the getter on the instance at dump time, which I verified before relying on it.

What is deliberately not here: --sql. The DDL is built inside the repository at execution time, interleaved with decisions that are only made then — whether DETACH CONCURRENTLY falls back to the blocking form because a DEFAULT sibling exists, how rows a DEFAULT partition holds for a new window get moved, which orphan marker gets cleared, the lock_timeout and retry loop around a drop. A faithful renderer would mean a render/execute split across the two most safety-critical modules in the project (creator.py, remover.py, ~1400 lines) and would still not be able to pre-render the runtime branches. A "representative" renderer that omitted them would be read as a transcript in exactly the cases a review exists to catch. So the plan stays the contract — what, why, how big, what it locks — and the docs say why.

Stacked on the metrics PR.

Every operation carried its capabilities -- the heaviest lock it takes and
on what, and whether it can run inside a transaction block -- as a property,
so the plan a file held had lost the one thing a DBA reads before agreeing
to a window. capabilities and is_destructive are now computed fields:
serialized on the way out, ignored on the way in, so the round trip holds
and a saved plan is reviewable for its locks without the CLI.

plan --locks prints the same for a person, one operation per line and the
lock beneath it, with the operations that cannot run inside a transaction
block marked: they are the ones a crash leaves half-done.

There is deliberately no --sql. The DDL is built at execution time from
decisions only made then -- a concurrent detach falling back to the blocking
form, rows moved out of a DEFAULT partition, an orphan marker cleared -- and
a rendering without them would be read as a transcript in exactly the cases
a review exists to catch. The plan is the contract: what, why, how big, and
what it locks.
@AlexeyShalaev

Copy link
Copy Markdown
Member Author

Folded into #43, one PR for the whole epic; this branch stays for history.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant