Fine grained privileges to use `set tiflash replica <n>`
Nobody has claimed this yet.
- 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:
- Startup tiup playground with
--tiflash 1option
tiup playground --tiflash 1
- Open another terminal to connect to the tiup playground instance as root.
mysql --comments --host 127.0.0.1 --port 4000 -u root
- As a root user, create
test1database.
create database test1;
- As a root user, create
user1anduser2users.
Theuser1has all privileges on all oftest1database.user2has onlyalterprivileges ontest1database.
create user 'user1'@'localhost';
create user 'user2'@'localhost';
grant all privileges on test1.* to 'user1'@'localhost';
grant alter on test1.* to 'user2'@'localhost';
-
Exit the root connection
-
Connect to tiup playground instance as user1
mysql --comments --host 127.0.0.1 --port 4000 -u user1;
- Use
test1database and createt1table
use test1;
create table t1 (id int not null auto_increment, primary key(id));
insert into t1 values();
-
Exit the user1 connection
-
Connect to tiup playground instance as user2
mysql --comments --host 127.0.0.1 --port 4000 -u user2;
- Execute
alter table test1.t1 addcolumn
mysql> alter table test1.t1 add var varchar(10);
Query OK, 0 rows affected (0.69 sec)
- 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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