Repository navigation
Description
Had four gaps against 0.4.0 and was about to send PRs. Read 1.0.0 first — two are already fixed, and better than what I'd written. The other two are below.
Already fixed in 1.0.0
- Per-partition isolation. On 0.5.0
continue_on_errorisolated per step: one failingbefore_dropabandoned every partition behind it, anddropped_countcame back0even for drops already committed. The plan/executor rewrite fixes it as a side effect —PlanExecutorloopsfor op in plan.operations, per-opexcept,MaintenanceIssue(partition_name=op.target). - Retention as a policy.
RetentionPolicy = PredicatewithKeepNewest/KeepFor/KeepBehind/ExpireIf/SqlPredicate/Callback+AllOf/AnyOf/Notis well past the pluggable policy I was going to propose. Batching the SQL questions in the introspector is better than the per-run callback I had.
Nothing needed on either. 👍
1. Construction helper (additive)
getting-started/first-table.md still wires the collaborators by hand. Count isn't the problem — silent disagreement is:
PostgresPartitionRepository(engine) # ddl_timezone defaults to "UTC"
PostgresMetadataProvider(engine) # ddl_timezone defaults to NoneThree settings live on two objects and must match:
marker_prefix— stamps detached partitions and decides what counts as managed when dropping. Set on one only → safe-drop stops recognising its own orphans.ddl_timezone— writes naive boundaries and reads them back inis_partition_closed. Differing defaults mean atimestamp-keyed table in a non-UTC session is inconsistent before anyone passes an argument.boundary_codec— must match whatever encoded the bounds.
Proposal: PartitionToolkit.from_engine(engine, config, ...) → parts by name (repo, metadata, locks, service, maintainer). Parts rather than just a maintainer, so callers using metadata.is_partition_closed or locks.acquire_lock directly don't build a second set to keep consistent.
Written and tested against 0.5.0; port to 1.0.0 is straightforward.
2. Hook arguments
before_create taking PartitionInfo in 1.0.0 is the right direction. Drop/detach didn't move:
def before_detach(self, table_name: str, partition: PartitionInfo) -> None: ...
def after_detach(self, table_name: str, partition_name: str) -> None: ...
def before_drop(self, table_name: str, partition_name: str) -> None: ...
def after_drop(self, table_name: str, partition_name: str) -> None: ...- A
before_dropthat exports the partition wants its upper bound. Gets a string → re-queries the catalog for what the run held one frame up. after_detachgetspartition.nameon the line afterbefore_detachgotpartition.
Option A — one PartitionHookContext for all six: phase, table, partition name, plus config / PartitionInfo / boundaries / window where known. Makes drop hooks whole; lets one method serve every phase (an audit or metrics hook can't be written against six signatures today); next addition is a field, not a signature change.
Cost: breaks every hook days after a major — and at runtime, not import. runtime_checkable only checks the attribute exists, so an unported hook is accepted at wiring time and raises TypeError on first fire. Your call, not mine.
Option B — additive: leave the signatures, widen after_detach / before_drop / after_drop to accept PartitionInfo alongside the name.
Asking before writing
- Is the construction helper something you want in the library, or deliberately left to callers?
- Hooks: A, B, or not now given how recent 1.0.0 is?
Happy to send both as separate PRs, helper first. "Neither" is a fine answer — just didn't want to open a PR you'd have to decline.
Activity
[-]1.0.0 covers isolation and retention; a construction helper and richer hook arguments are still open[/-][+]Still open after 1.0.0: a construction helper, and what hooks are handed[/+]fix: refuse a mismatched orphan marker, and let the boundaries answer…
feat: one event for every lifecycle hook
fix: close the review findings on the hook event
Merge pull request #31 from bedrock-python/fix/naive-bound-without-a-…
AlexeyShalaev commentedon Sep 1, 2026
Both halves are answered, and the second one went further than you proposed. Everything below is on
masterand goes out in 1.1.0, whose release PR is open.1. The construction helper — no, but the defect under it is fixed
You put it exactly right: count isn't the problem, silent disagreement is. A helper only protects the code that adopts it, and everyone integrating today wired the collaborators by hand — they would have kept the footgun. So the three settings were dealt with where they actually couple:
marker_prefix— the only one that affects maintenance, and the one that failed silently: detached partitions simply stop being discovered, so nothing is ever dropped.PartitionLifecycleServicenow refuses a repository/provider pair that disagrees, at construction, the way it already refused a calendar/DDL timezone pair. A custom implementation that declares no prefix is trusted and skipped (OrphanMarkerAware).ddl_timezoneandboundary_codec— used byis_partition_closedalone, and the object that knows both is the table's ownTimeBoundaries. It can now be handed over directly:is_partition_closed(name, boundaries=config.time_boundaries). The constructor arguments stay for callers without a config at hand.A factory is still on the table as ergonomics rather than safety, and if it lands it will most likely be a function returning the service plus readable
.repository/.metadata/.locks, taking pre-built parts for anything exotic rather than re-declaring fourteen constructor arguments. Not in this release.2. Hooks — Option A, in full
Every hook method now takes one
PartitionEvent:phase,config,partition,window,operation. So abefore_dropthat archives a partition is handed the period it covers, the reason retention gave, and the size the policy measured, instead of a name.Two things beyond what you asked for:
on_event— your parenthesis about an audit hook not being writable against six signatures was the sharpest line in the issue. It fires for every phase, just before the method named for it, so abefore_*that refuses an operation by raising still leaves the audit trail with the attempt in it.before_attach/after_attach— a partition retention released is re-attached when its window is wanted again, and that transition used to happen silently. An export taken while it was detached goes stale the moment it returns, and nothing told the hook.Shipped in a minor, knowingly against semver: the library is days old with nothing depending on it, and the alternative was carrying the split until a major. You named the cost yourself — an unported hook is accepted by a runtime-checkable protocol and fails at its first call — so hook signatures are now read when the service is constructed, and a 1.0-shaped method is refused there, naming the class, the method and the shape to move to. The changelog carries a before/after table for every method.
Two notes on your facts, since you were precise about them
The
ddl_timezone/boundary_codecinconsistency is real but narrower than the issue implies: nothing inside the library callsis_partition_closed, so maintenance was never affected.And
before_dropwas worse off than you wrote. It cannot re-query the catalog for the bound at all —DETACHclearsrelpartbound(verified on 17), so for an orphan detached by an earlier run the database no longer records where it sat. The name is the only evidence left, which is why the planner decodes it too, and why the event now carries that reading rather than leaving each hook to repeat it.Thanks for this — it was a careful read of a release that was four days old, and it made 1.1 better than it would have been. If you still want the one-method-for-every-phase idea taken further, or the helper, open a proposal and I will look at it seriously.
AlexeyShalaev commentedon Sep 2, 2026
1.1.0 is on PyPI, and this closes with it.
Hooks (your Option A, in full). Every hook method takes one
PartitionEvent;on_eventfires for every phase;before_attach/after_attachcover the transition that used to be silent; and a hook still written to the 1.0 signatures is refused when the service is constructed, not at its first call. The before/after table for every method is in the release notes.The three settings. A mismatched
marker_prefixis refused at construction,is_partition_closed(name, boundaries=config.time_boundaries)takes the codec and timezone from the table's own configuration, and the remaining silent case, a naive bound with neither given, warns.The helper. I said "not in this release" above, and that held for 1.1.0. It then turned out the command line needed exactly that wiring, so
PartitionToolkit.from_engine(engine, ...)is in #43 for the next minor: parts by name (repo,metadata,locks,service,maintainer), in both mirrors, withPartitionToolkit(...)for holding parts of your own. Close to what you described.If something here still does not match what you needed, a new issue is the right place; this one has done its work.