matrixorigin / matrixorigin/matrixone

[Enhancement]: Clean historical orphan object privileges from mo_role_privs

Open
#27,836 0 comments 0 reactions 1 assignee Claimed by @Ariznawlll View on GitHub
kind/enhancement severity/s0
Dominant language
Go
Stars
1.9k
Forks
311
Avg merge
1d 3h
Merged PRs (30d)
768

Description

## Background

Issue #27723 fixes object-scoped privilege cleanup for future DROP TABLE / DROP DATABASE / DROP VIEW / DROP SEQUENCE operations. It intentionally cannot discover privilege rows whose referenced catalog objects were already removed before the fix was deployed.

## Problem

Historical `mo_catalog.mo_role_privs` rows may reference database or relation logical IDs that no longer exist. Object IDs are not reused, so this is not a known privilege-escalation path, but the rows remain permanent metadata bloat unless an upgrade or bounded maintenance path removes them.

## Proposed scope

- Define orphan predicates separately for database- and relation-scoped privileges.
- Preserve account/global privileges (`obj_id = 0`) and tenant isolation.
- Clean in bounded pages with restart-safe/idempotent behavior.
- Integrate with the supported upgrade or catalog-maintenance lifecycle.
- Add upgrade/restart coverage for pre-existing orphan rows and live-object controls.

## Acceptance criteria

- Pre-upgrade orphan object privilege rows are removed after the supported maintenance/upgrade path.
- Live database/table/view/sequence privilege rows remain unchanged.
- Account/global privilege rows remain unchanged.
- Work is bounded and safe to resume after interruption.

## Related

- #27723
- #27745

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.