Tablet init super read only#77
Conversation
b730d1f to
7a426aa
Compare
404ed69 to
fcea2d8
Compare
058cd6b to
bc58cb5
Compare
b3c996d to
21cc81e
Compare
0904832 to
58a1e92
Compare
There was a problem hiding this comment.
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.
rohit-nayak-ps
left a comment
There was a problem hiding this comment.
I have done a quick read through of the changes without really following the new flow. Hope to do that tomorrow. I will also look at all the tests where we are expecting different results now.
Suggested some minor typos/stylistic changes and asked some clarifications.
config/embed.go
Outdated
There was a problem hiding this comment.
Did you try checking if the underlying database is mysql or mariadb inside init_db.sql?
There was a problem hiding this comment.
I discussed it initially with other team members .. and I concluded it will make code complex if we put that logic in .sql file .. or we might need to create templates. Furthermore Maria DB is going to be deprecated anyways in future release.
There was a problem hiding this comment.
Why do we have conditional code for a tablet with version less than 16?
There was a problem hiding this comment.
For downgrade / upgrade test, tablet version < 16 will not have super read only code handling. Therefore we are explicitly setting super-read-only to false here.
There was a problem hiding this comment.
The fakesqldb condition is commented out: intended?
There was a problem hiding this comment.
There's a lot of stuff commented out (mixing of multi-line and single line comments, etc) and it's not clear what is intended and why.
There was a problem hiding this comment.
@Rohit, this was commented out to show you, these changes from you PR is not needed .. But I have removed it now... You don't need to add these specific checks here instead I use existing structure of fakesqldb..
There was a problem hiding this comment.
why do we need super readonly handling here: does the test run DDLs?
There was a problem hiding this comment.
Yeah these test does not have vttablets. They just create mysql instance and run test against them...
config/init_db.sql
Outdated
There was a problem hiding this comment.
instead of adding this, can't we just look for the line in the file that sets the readonly and add our custom commands above that?
There was a problem hiding this comment.
I thought that would be more risky ... we don't know how would it react if client provide their own int_db.sql and it has some statements which does turns out true for our condition of readonly... Hence I thought this will be much cleaner approach...
go/mysql/query.go
Outdated
There was a problem hiding this comment.
we should extract this code which is repeated in multiple functions here, into a utility function
config/embed.go
Outdated
There was a problem hiding this comment.
We can remove the MariaDB specific stuff in v16+ vitessio#9518. We still want to support importing/migrating from MariaDB into Vitess, but in that case the MariaDB instance would be external with an unmanaged tablet so init would not apply.
There was a problem hiding this comment.
The import/migration test is using init_db.sql which now have super-read-only and therefore it fails. This is added to make sure our import/migrate test uses init_db specific to maria db...
config/init_testserver_db.sql
Outdated
There was a problem hiding this comment.
What is this file for? Is it for vttestserver/vtcombo? What's unique about that compared to standard and then below, unit test cases? We can add a comment at the top to explain. It feels like this is part of a larger problem in that we're not testing super_read_only in many tests.
There was a problem hiding this comment.
We are testing super-read-only for all the cases.
- super-read-only does not make sense for unit test .. therefore I have come up with new config/init_unit_test_db.sql
- testserver/vtcombo does not operate in same manner.. it uses same sql instance for all the vttablet under the hood so we have to get rid of super-read-only in this case as well , hence config/init_testserver_db.sql
- Every other test e2e and backup/restore etc uses init_db.sql file, which has super-read-only.
config/mycnf/test-suite.cnf
Outdated
There was a problem hiding this comment.
This change can have wide impacts. IMO, we should test it in as many ways as possible. i.e. we should use super-read-only in all of the tests, if possible.
There was a problem hiding this comment.
test-suite is used only in vttestserver. VtTestserver uses vtcombo which has one sql instance for all vttablet. We cannot turn 'on/'off' super-read-only because it will make vtcombo confuse due to one instance of mysql for all vttablets.
There was a problem hiding this comment.
Are we using vttestserver in our test/e2e , i don't see instances where we are...
There was a problem hiding this comment.
This is another case where it feels like we're avoiding testing the fact that Vitess works properly when super_read_only is enabled. No?
There was a problem hiding this comment.
if you closely look at I have introduced a flag 'withSuperReadOnly' ... during test setup we introduce errantGTID (https://github.com/planetscale/vitess/pull/77/files#diff-9162b364b991658ff1575922d4a008aecc15e44fd27e64678f24cce330033d9fR108) thats the only place where we pass true to this flag. For all other places we keep it false. Hence the tests are running with super-read-only false.
go/vt/mysqlctl/mysqld.go
Outdated
There was a problem hiding this comment.
Better to cast it to a MySQLError and check the error code.
There was a problem hiding this comment.
this is how we are doing check for something not part of specific mysql version... we want to warn if super-read-only is not supported in case of db like mariadb and erorr in all other cases. We are not checking any specific mysql erorr.
go/vt/mysqlctl/mysqld.go
Outdated
There was a problem hiding this comment.
How is this function directly/exclusively tied to restores? If someone runs the equivalent of mysqldump foo.10 | mysql, it would be bad if mysqld automatically disabled super_read_only rather than protecting you as it should.
5952836 to
d03a02b
Compare
8eaceaf to
c9b7c05
Compare
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
Signed-off-by: Manan Gupta <manan@planetscale.com>
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
f824ef0 to
fe21638
Compare
Signed-off-by: Rameez Sajwani <rameezwazirali@hotmail.com>
Signed-off-by: Manan Gupta <manan@planetscale.com>
|
please review vitessio#12206 instead. |
Description
Please review https://github.com/vitessio/vitess/pull/12206/files instead.
This change is build on top of vitessio#11520, where instead of using
withddlwe use declarative approach. Using declarative approach helps us condense all our schema changes to one place. This provide us an opportunity to applysuper-read-onlychanges to our DB. As ofwithddlis used across schema engines with make it hard to dosuper-read-onlychange.What is super-read-only change
As of today all replicas comes up in read-only mode, however this doesn't prevent user's like
rootandvt_dbawho haveSUPERprivileges to change the database anytime anywhere. We want to leverage GLOBALsuper_read_onlyconfiguration in order to protect against errant GTIDs. This will make sure that apart from primary no other component or offline system can mutate DB resulting in errant GTIDs that are then lying in wait to cause later failures, as you can see in vitessio#9312 and vitessio#10094Furthermore not all the uses-cases are ensuring that we end up replica in read-only mode. During ERS there are cases where we don't set the read-only. With super-read-only change we will make sure that we cover those cases as well.
Details
This PR usese vitessio#11520 as a building block. I am listing major changes below to help you review the PR.
MariaDBdoesn't have super-read-only, therefore we need to come up with a separate init_db for it.For Reference
Some related work items done in the past
vitessio#10363
vitessio#11706
vitessio#10094
vitessio#9312
vitessio#10448
Unresolved Issued during code changes:
I have filed few issues which I will need to resolve once I check-in this PR.
use_super_read_onlyflag from VTTtablet vitessio/vitess#12140Related Issue(s)
vitessio#12180
Checklist
Deployment Notes