Repository navigation
fix: rebind role privilege object IDs during restore - #26700
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
758f29c to
f5fe311
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep-reviewed at 21342a3.\n\nThe previous cluster-restore blocker is closed: publication owners are resolved by stable account name, creator users and owner roles are rebound from snapshot IDs through stable names to current tenant-local IDs, and the database ID is resolved inside the restored publisher. Missing identities now fail explicitly instead of dereferencing a historical account ID. The regression recreates both publisher and subscriber and verifies the restored publication account/database IDs.\n\nThe original privilege fix also preserves the distinct ID contracts: database-scoped grants map to target database IDs, direct table/view grants map to relation logical IDs, wildcard zero remains a sentinel, and grants for deliberately omitted objects are removed rather than retaining a collision-prone source ID. Post-object handlers run after FK/view and publication/subscription phases for account snapshot, account PITR, and cluster restore.\n\nValidated the full pkg/frontend test suite, all three TestIssue26640 embedded-cluster regressions, go vet for frontend and issues, and git diff --check. CI is green.
|
Queued — the merge queue status continues in this comment ↓. |
Merge Queue Status
This pull request spent 43 minutes 10 seconds in the queue, including 42 minutes 47 seconds running CI. Required conditions to merge
|
) Snapshot and PITR restore copy system-catalog rows before all target objects have been recreated. Identity-bearing rows therefore cannot blindly retain source physical IDs. In particular, restored `mo_role_privs.obj_id` values could point to source objects instead of the target database or relation, leaving valid privileges unusable after restore. This PR: - introduces explicit restore policies and ordered post-restore handlers for identity-bearing system catalogs; - rebuilds database privilege object IDs with target physical database IDs; - rebuilds table and view privilege object IDs with target relation logical IDs; - keeps snapshot reads scoped to the source account while resolving and writing identities in the target account; - preserves cluster restore ordering for publications and subscription databases; - adds snapshot, PITR, cross-account, cluster-subscription, validation, and failure-path regression coverage. Validation: - `.agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/frontend -count=1` - `.agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/tests/issues -run "^TestIssue26640" -count=1` - focused race tests with `-count=100` - full `pkg/frontend` race suite - `go vet ./pkg/frontend ./pkg/tests/issues` - `git diff --check` - changed-code CI coverage: `117/139 (84.17%)` Approved by: @XuPeng-SH
) Snapshot and PITR restore copy system-catalog rows before all target objects have been recreated. Identity-bearing rows therefore cannot blindly retain source physical IDs. In particular, restored `mo_role_privs.obj_id` values could point to source objects instead of the target database or relation, leaving valid privileges unusable after restore. This PR: - introduces explicit restore policies and ordered post-restore handlers for identity-bearing system catalogs; - rebuilds database privilege object IDs with target physical database IDs; - rebuilds table and view privilege object IDs with target relation logical IDs; - keeps snapshot reads scoped to the source account while resolving and writing identities in the target account; - preserves cluster restore ordering for publications and subscription databases; - adds snapshot, PITR, cross-account, cluster-subscription, validation, and failure-path regression coverage. Validation: - `.agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/frontend -count=1` - `.agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/tests/issues -run "^TestIssue26640" -count=1` - focused race tests with `-count=100` - full `pkg/frontend` race suite - `go vet ./pkg/frontend ./pkg/tests/issues` - `git diff --check` - changed-code CI coverage: `117/139 (84.17%)` Approved by: @XuPeng-SH
) Snapshot and PITR restore copy system-catalog rows before all target objects have been recreated. Identity-bearing rows therefore cannot blindly retain source physical IDs. In particular, restored `mo_role_privs.obj_id` values could point to source objects instead of the target database or relation, leaving valid privileges unusable after restore. This PR: - introduces explicit restore policies and ordered post-restore handlers for identity-bearing system catalogs; - rebuilds database privilege object IDs with target physical database IDs; - rebuilds table and view privilege object IDs with target relation logical IDs; - keeps snapshot reads scoped to the source account while resolving and writing identities in the target account; - preserves cluster restore ordering for publications and subscription databases; - adds snapshot, PITR, cross-account, cluster-subscription, validation, and failure-path regression coverage. Validation: - `.agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/frontend -count=1` - `.agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/tests/issues -run "^TestIssue26640" -count=1` - focused race tests with `-count=100` - full `pkg/frontend` race suite - `go vet ./pkg/frontend ./pkg/tests/issues` - `git diff --check` - changed-code CI coverage: `117/139 (84.17%)` Approved by: @XuPeng-SH
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #26640
What this PR does / why we need it:
Snapshot and PITR restore copy system-catalog rows before all target objects have been recreated. Identity-bearing rows therefore cannot blindly retain source physical IDs. In particular, restored
mo_role_privs.obj_idvalues could point to source objects instead of the target database or relation, leaving valid privileges unusable after restore.This PR:
Validation:
.agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/frontend -count=1.agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/tests/issues -run "^TestIssue26640" -count=1-count=100pkg/frontendrace suitego vet ./pkg/frontend ./pkg/tests/issuesgit diff --check117/139 (84.17%)