-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Initialize Tablet with super_read_only mode #12206
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 44 commits
14dcc78
b5caff3
d64bab0
c7bcd52
978d02c
6a9c93d
8b14bed
014115a
c4eb7f0
8374e14
a52c1bc
eac4d6a
c196413
ce52ba4
cc6cf01
4e0bd80
215f318
4da62a4
8c4e933
e8afcab
3c26c6b
46ab550
a3804ca
deba5c7
d443df5
31664d7
e7a8aeb
b07097d
349a302
2a1f185
0a4f29e
e8a9851
cc37e73
dac1d46
36f3628
d94f977
e31ec31
5b32fd4
272814f
fd9df61
1f2df82
89c1b4b
8e158e2
185cf53
b81b354
7fe7a89
4ead779
402b449
3d1435d
8997da5
8556879
12ddd17
d4e9ef1
5c5ca78
9153e19
bd84f1c
234d89c
a653287
e3d1607
2d7636f
f3b1958
fdc2eef
525afb9
f7b3546
47ee6ad
1723696
2be3147
cf9b781
422b7cc
30f36d6
b1683bd
ca0aefe
1980366
53ea516
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 |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| # This file is for testing purpose only. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-production version of init_db.sql. This will be similar to init_db.sql except super_read_only handling. |
||
| # 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 |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| ## Summary | ||
|
|
||
| - [New command line flags and behavior](#new-command-line-flags-and-behavior) | ||
|
|
||
| ## Known Issues | ||
|
|
||
| ## Major Changes | ||
|
|
||
| ### New command line flags and behavior | ||
|
|
||
| #### VTTablet: Initializing all replica DB with super_read_only | ||
| In order to prevent SUPER privileged users like `root` or `vt_dba` to produce errant GTIDs anywhere anytime, all the replica DBs are initialized with the Mysql | ||
| global variable `super_read_only` value set to `ON`. During re-parenting, we set `super_read_only` to `OFF` for the promoted primary tablet. This will allow the | ||
| primary to accept writes. All replica except the primary will still have their global variable `super_read_only` set to `ON`. This will make sure that apart from | ||
|
rsajwani marked this conversation as resolved.
Outdated
|
||
| the replication no other component or offline system can mutate replica DB resulting in errant GTIDs that are then lying in wait to cause later failures. | ||
|
rsajwani marked this conversation as resolved.
Outdated
|
||
|
|
||
| Reference PR for this change is [PR #12206](https://github.com/vitessio/vitess/pull/12206) | ||
| 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) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These test does not have vttablets. They just create mysql instance and run test against them... |
||
| require.NoError(t, err, "failed to execute %q: %v", query, err) | ||
|
|
||
| return res | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.