-
Notifications
You must be signed in to change notification settings - Fork 13
Tablet init super read only #77
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
Changes from all commits
2b62a33
1576a33
7ba072e
0b7fa6a
50e7907
d6b13f1
9fef193
8ff1c42
a3b1ffa
e5c772a
093e6cc
4c99a57
a64fd4d
80879a2
30aa865
5c7eb2e
ee952a4
881f50b
a8b230a
605a308
3bedb2b
1256c71
211253e
c025af6
32789e6
c857d25
c263a57
7f5d871
3d7bf35
dca3838
7d43d0b
cfa97fe
fad2b7d
473fe4a
0f4b189
fe21638
62a4a22
9330333
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,12 @@ | |
| ############################################################################### | ||
| # Equivalent of mysql_secure_installation | ||
| ############################################################################### | ||
| # We need to ensure that super_read_only is disabled so that we can execute | ||
| # these commands. Note that disabling it does NOT disable read_only. | ||
| # We save the current value so that we only re-enable it at the end if it was | ||
| # enabled before. | ||
| SET @original_super_read_only=IF(@@global.super_read_only=1, 'ON', 'OFF'); | ||
| SET GLOBAL super_read_only='OFF'; | ||
|
|
||
| # Changes during the init db should not make it to the binlog. | ||
| # They could potentially create errant transactions on replicas. | ||
|
|
@@ -77,3 +83,9 @@ FLUSH PRIVILEGES; | |
|
|
||
| RESET SLAVE ALL; | ||
| RESET MASTER; | ||
|
|
||
| # custom sql is used to add custom scripts like creating users/passwords. We use it in our tests | ||
| # add custom sql here | ||
|
||
|
|
||
| # We need to set super_read_only back to what it was before | ||
| SET GLOBAL super_read_only=IFNULL(@original_super_read_only, 'OFF'); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| # This file is for testing purpose only. | ||
| # This file is executed immediately after mysql_install_db, to initialize a fresh data directory. | ||
| # It is equivalent of init_db.sql. Given init_db.sql is for mysql which has super_read_only | ||
| # related stuff therefore for testing purpose we avoid setting `super_read_only` during initialization. | ||
|
|
||
| ############################################################################### | ||
| # WARNING: Any change to init_db.sql should gets reflected in this file as well. | ||
| ############################################################################### | ||
|
|
||
| ############################################################################### | ||
| # WARNING: This sql is *NOT* safe for production use, | ||
| # as it contains default well-known users and passwords. | ||
| # Care should be taken to change these users and passwords | ||
| # for production. | ||
| ############################################################################### | ||
|
|
||
| ############################################################################### | ||
| # Equivalent of mysql_secure_installation | ||
| ############################################################################### | ||
| # We need to ensure that read_only is disabled so that we can execute | ||
| # these commands. | ||
| SET GLOBAL read_only='OFF'; | ||
|
|
||
| # Changes during the init db should not make it to the binlog. | ||
| # They could potentially create errant transactions on replicas. | ||
| SET sql_log_bin = 0; | ||
| # Remove anonymous users. | ||
| DELETE FROM mysql.user WHERE User = ''; | ||
|
|
||
| # Disable remote root access (only allow UNIX socket). | ||
| DELETE FROM mysql.user WHERE User = 'root' AND Host != 'localhost'; | ||
|
|
||
| # Remove test database. | ||
| DROP DATABASE IF EXISTS test; | ||
|
|
||
| ############################################################################### | ||
| # Vitess defaults | ||
| ############################################################################### | ||
|
|
||
| # Admin user with all privileges. | ||
| CREATE USER 'vt_dba'@'localhost'; | ||
| GRANT ALL ON *.* TO 'vt_dba'@'localhost'; | ||
| GRANT GRANT OPTION ON *.* TO 'vt_dba'@'localhost'; | ||
|
|
||
| # User for app traffic, with global read-write access. | ||
| CREATE USER 'vt_app'@'localhost'; | ||
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, FILE, | ||
| REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, | ||
| LOCK TABLES, EXECUTE, REPLICATION CLIENT, CREATE VIEW, | ||
| SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER | ||
| ON *.* TO 'vt_app'@'localhost'; | ||
|
|
||
| # User for app debug traffic, with global read access. | ||
| CREATE USER 'vt_appdebug'@'localhost'; | ||
| GRANT SELECT, SHOW DATABASES, PROCESS ON *.* TO 'vt_appdebug'@'localhost'; | ||
|
|
||
| # User for administrative operations that need to be executed as non-SUPER. | ||
| # Same permissions as vt_app here. | ||
| CREATE USER 'vt_allprivs'@'localhost'; | ||
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, FILE, | ||
| REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, | ||
| LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, | ||
| SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER | ||
| ON *.* TO 'vt_allprivs'@'localhost'; | ||
|
|
||
| # User for slave replication connections. | ||
| CREATE USER 'vt_repl'@'%'; | ||
| GRANT REPLICATION SLAVE ON *.* TO 'vt_repl'@'%'; | ||
|
|
||
| # User for Vitess VReplication (base vstreamers and vplayer). | ||
| CREATE USER 'vt_filtered'@'localhost'; | ||
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, FILE, | ||
| REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, | ||
| LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, | ||
| SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER | ||
| ON *.* TO 'vt_filtered'@'localhost'; | ||
|
|
||
| # User for general MySQL monitoring. | ||
| CREATE USER 'vt_monitoring'@'localhost'; | ||
| GRANT SELECT, PROCESS, SUPER, REPLICATION CLIENT, RELOAD | ||
| ON *.* TO 'vt_monitoring'@'localhost'; | ||
| GRANT SELECT, UPDATE, DELETE, DROP | ||
| ON performance_schema.* TO 'vt_monitoring'@'localhost'; | ||
|
|
||
| FLUSH PRIVILEGES; | ||
|
|
||
| RESET SLAVE ALL; | ||
| RESET MASTER; | ||
|
|
||
| # custom sql is used to add custom scripts like creating users/passwords. We use it in our tests | ||
| # add custom sql here |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,3 +23,4 @@ sql_mode = STRICT_TRANS_TABLES | |
|
|
||
| # set a short heartbeat interval in order to detect failures quickly | ||
| slave_net_timeout = 4 | ||
| super-read-only = false | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -137,7 +137,7 @@ func verifyWeightString(t *testing.T, local collations.Collation, remote *remote | |
| } | ||
|
|
||
| func exec(t *testing.T, conn *mysql.Conn, query string) *sqltypes.Result { | ||
| res, err := conn.ExecuteFetch(query, -1, true) | ||
| res, err := conn.ExecuteFetchWithSuperReadOnlyHandling(query, -1, true) | ||
|
||
| require.NoError(t, err, "failed to execute %q: %v", query, err) | ||
|
|
||
| return res | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vttablet + mysqlctl + mysqlctld needs to be always at the same version during upgrades and downgrades. I am taking this assumption after talking to different folks and it look logical to me as well.