Repository navigation
feat: apply, and the artifact between plan and apply - #37
Closed
AlexeyShalaev wants to merge 1 commit into
Closed
AlexeyShalaev wants to merge 1 commit into
AlexeyShalaev wants to merge 1 commit into
Conversation
pg-partsmith apply carries maintenance out, and withholds every destructive operation unless --allow-destructive is given. The safe behaviour is the default one rather than a second mode somebody has to remember to select, which is also exactly the init-container case: create the partitions the application is about to write into, retire nothing at startup. plan --save writes the artifact and apply --plan reads it back, so what runs is what was reviewed. Both guards from the first commit of this branch stand behind it: a plan made for another table, or under a configuration that has since been edited, is refused before any DDL, with --allow-config-drift to override deliberately. With no --plan, planning and applying go under one lock through maintain(), which is also what finalizes an interrupted DETACH CONCURRENTLY before the rest of the run is decided. The envelope is now built by every command rather than only when JSON was asked for: it is what --save writes, and building it costs nothing. The result's plan is dumped beside the result because MaintenanceResult excludes it from serialization -- an audit log wants what was done and why, not counters with nothing saying what they counted.
Member
Author
|
Folded into #43, one PR for the whole epic; this branch stays for history. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 1 of #32, second half:
apply.Destructive operations are withheld unless asked for. Without
--allow-destructive,applycreates and re-attaches and retires nothing. That makes the safe behaviour the default one rather than a second mode somebody has to remember to select — and it collapses the epic's "one-shot mode and init-container mode" into one flag: the init container is justapplywith nothing extra, which is exactly what running retention at application startup should not do.The artifact:
pg-partsmith plan -c partitions.yaml --save plan.json # zero DDL pg-partsmith apply -c partitions.yaml --plan plan.json --allow-destructiveBoth guards from #33 stand behind it: a plan made for another table, or under a configuration since edited, is refused with exit
4before any DDL.--allow-config-driftoverrides deliberately.With no
--plan, planning and applying go under one lock throughmaintain(), which is also what finalizes an interruptedDETACH … CONCURRENTLYbefore deciding the rest of the run.--continue-on-errormaps onto the library's own isolation, so decision 8 in the epic needed no new mechanism.The envelope is now built by every command rather than only for JSON — it is what
--savewrites, and it costs nothing. The result's plan is dumped beside the result, becauseMaintenanceResultexcludes it from serialization and an audit log wants what was done and why, not counters with nothing saying what they counted.32 unit tests + 11 against a real PostgreSQL, including plan → save → apply and the refusal of a plan whose document has since been edited.