Skip to content

[BugFix] fix the privilege issue DROP STATS command (backport #55695) #55777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 11, 2025

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Feb 11, 2025

Why I'm doing:

What I'm doing:

Introduced by #55400.

  • When executing DELETE sql, it will construct an SELECT sql to do partition pruning. But the user may have different privilege on DELETE and SELECT, which means that user may have privilege to DELETE but no privilege to perform SELECT
  • One example is DROP STATS xxx command, it will execute an DELETE FROM table_statistics_v1 SQL, which should use the ROOT user, otherwise may lack the right privilege. But there's a bug with it, which doesn't bind the session to thread-local, so DELETE still uses the original user but not root

To address this, we need to do several fixes:

  • Bypass the privilege check when planning SELECT in DELETE, to avoid the privilege issue
  • Correctly bind the thread-local session for DROP STATS and other commands

Alternatives:

  • Solution 1: invoke only necessary optimizer components to do partition pruning, rather than constructing a sql directly. Why don't we choose this approach?
    • In theory we should have a DeletePlanner, which can do partition pruning for DELETE statement, so we don't have to do it in DeleteMgr which should be responsible for execution. But unfortunetely we don't have it, and the query plan of DELETE is pretty naive.
    • Or can we invoke the optimizer components to do partition pruning in DeleteMgr, but partition pruning has pretty much dependency on other components like predicate simplification & pushdown, it needs to copy pretty much duplicate code like StatementPlanner::plan
    • So in result this approach will make the problem more complicated

Fixes #issue

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Copy link
Contributor Author

mergify bot commented Feb 11, 2025

Cherry-pick of 18f1714 has failed:

On branch mergify/bp/branch-3.4/pr-55695
Your branch is up to date with 'origin/branch-3.4'.

You are currently cherry-picking commit 18f171426.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   fe/fe-core/src/main/java/com/starrocks/load/DeleteMgr.java
	modified:   fe/fe-core/src/main/java/com/starrocks/qe/ConnectContext.java
	modified:   fe/fe-core/src/main/java/com/starrocks/qe/scheduler/dag/PhasedExecutionSchedule.java
	modified:   fe/fe-core/src/main/java/com/starrocks/sql/StatementPlanner.java
	modified:   fe/fe-core/src/main/java/com/starrocks/statistic/AnalyzeMgr.java

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   fe/fe-core/src/main/java/com/starrocks/qe/StmtExecutor.java

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@mergify mergify bot added the conflicts label Feb 11, 2025
@wanpengfei-git wanpengfei-git enabled auto-merge (squash) February 11, 2025 02:10
@mergify mergify bot closed this Feb 11, 2025
auto-merge was automatically disabled February 11, 2025 02:10

Pull request was closed

Copy link
Contributor Author

mergify bot commented Feb 11, 2025

@mergify[bot]: Backport conflict, please reslove the conflict and resubmit the pr

@murphyatwork murphyatwork reopened this Feb 11, 2025
Signed-off-by: Murphy <[email protected]>
(cherry picked from commit 18f1714)
Signed-off-by: Murphy <[email protected]>

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/qe/StmtExecutor.java
@murphyatwork murphyatwork force-pushed the mergify/bp/branch-3.4/pr-55695 branch from 21b5cee to a75ff5a Compare February 11, 2025 02:20
@wanpengfei-git wanpengfei-git enabled auto-merge (squash) February 11, 2025 02:20
Copy link

@wanpengfei-git wanpengfei-git merged commit f17ba1e into branch-3.4 Feb 11, 2025
31 checks passed
@wanpengfei-git wanpengfei-git deleted the mergify/bp/branch-3.4/pr-55695 branch February 11, 2025 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants