pingcap / pingcap/tiflash

Fine grained privileges to use `set tiflash replica <n>`

Open
#7,797 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

type/feature-request
Dominant language
C++
Stars
1k
Forks
423
Avg merge
1d 15h
Merged PRs (30d)
24

Description

Feature Request

Is your feature request related to a problem? Please describe:
alter statement like alter table <table_name> set tiflash replica <n> DDL creates TiFlash replica.
Then the privileges to create/delete replica is alter.

I wish TiFlash has a file grained privileges to use set tiflash replica <n>. Like users can run 'alter table <table_name> add column' while it is prohibited to 'set tiflash replica '.

Describe the feature you'd like:
Create a dedicated privileges to allow/disallow users to run alter table <table_name> set tiflash replica <n>

Here are steps to represent this request:

  1. Startup tiup playground with --tiflash 1 option
tiup playground --tiflash 1
  1. Open another terminal to connect to the tiup playground instance as root.
mysql --comments --host 127.0.0.1 --port 4000 -u root
  1. As a root user, create test1 database.
create database test1;
  1. As a root user, create user1 and user2 users.
    The user1 has all privileges on all of test1 database. user2 has only alter privileges on test1 database.
create user 'user1'@'localhost';
create user 'user2'@'localhost';
grant all privileges on test1.* to 'user1'@'localhost';
grant alter on test1.* to 'user2'@'localhost';
  1. Exit the root connection

  2. Connect to tiup playground instance as user1

mysql --comments --host 127.0.0.1 --port 4000 -u user1;
  1. Use test1 database and create t1 table
use test1;
create table t1 (id int not null auto_increment, primary key(id));
insert into t1 values();
  1. Exit the user1 connection

  2. Connect to tiup playground instance as user2

mysql --comments --host 127.0.0.1 --port 4000 -u user2;
  1. Execute alter table test1.t1 add column
mysql> alter table test1.t1 add var varchar(10);
Query OK, 0 rows affected (0.69 sec)
  1. Execute alter table test1.t1 set tiflash replica <n>
mysql> alter table test1.t1 set tiflash replica 1;
Query OK, 0 rows affected (0.39 sec)
  • Expected behavior: Execute alter table test1.t1 set tiflash replica <n> should be prohibited for user2.
  • Actual behavior: Execute alter table test1.t1 set tiflash replica <n> is allowed for user2.

Describe alternatives you've considered:
No alternative solution found so far

Teachability, Documentation, Adoption, Migration Strategy:

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the privilege behavior with the documented tiup playground --tiflash 1 setup and the user1/user2 SQL commands. No source files or tests are named in the issue, so the privilege-checking path for ALTER TABLE must be located first. Done means user2 can still use ordinary ALTER operations but is prohibited from SET TIFLASH REPLICA.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, mysql
Domain
authorization, database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.