Repository navigation
schemachange: check the recorded owner's schema USAGE before discarding a dropped table's run - #738
Draft
Kiran01bm wants to merge 1 commit into
Conversation
Discarding a run whose table was dropped drops the shadow as the owner the row records; without USAGE on the schema it failed part-way with permission denied instead of refusing before anything was dropped.
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.
Discarding a stopped run whose table has since been dropped now checks that the table's recorded owner can reach the schema before it drops anything, as discarding a run on a table that still exists does.
Why
A copy-and-swap run that stops leaves a half-built copy of the table behind, and
pg-sprite discardcleans it up. The copy is dropped as the table's owner, so that owner needs access (USAGE) to the schema. The parent PR makes the discard of a table that still exists check this first. The discard of a table someone has dropped since the run stopped did not, so it could fail with "permission denied" part-way through.What
Runner.DiscardGonecallspreflight.CheckCopySwapOwnerUsagefor the owner and schema the checkpoint row records, after it has found the shadow and before the first drop. A run with no shadow left is not checked.CheckCopySwapOwnerUsagenow takes the owner, schema and table names rather than aCopySwapShape, since a dropped table has no shape to prove.Runner.Discardpasses its shape's names.USAGEafter the table is dropped. The discard is refused with aPrivilegeErrorgrantingUSAGEalone, and the copy and the row are still there. OnceUSAGEis granted again, the discard drops both. It fails on the parent branch.engine-role.mdsaysDiscardGonemakes the same check.Stacked on #736; merge that first.
Before / after
A run on
app.orders(owned byorders_owner) stopped while verifying. Then the table was dropped, andorders_ownerlostUSAGEon schemaapp.