Skip to content
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

tabletmanager revamp: refactor initialization #6311

Merged
merged 32 commits into from
Jun 24, 2020

Conversation

sougou
Copy link
Contributor

@sougou sougou commented Jun 15, 2020

This work is for #6131.

This change mainly focuses on refactoring how vttablet comes up. This change seems to have improved the flakyness of the endtoend tests, most likely because the new code is more aggressive about computing the mysql port, which makes everything else faster. Here's a summary of the changes:

  • Initializations parameters: init_keyspace, init_shard and init_tablet_type are now mandatory.
  • The demote_master_type flag has been deprecated, and we use the init_tablet_type in place of it.
  • ActionAgent has been renamed to TabletManager. There will not be much action left by the time we're done with the refactor.
  • TabletManager initialization uses a unified code path for all: vttablet, vtcombo and tests. You have to build the tablet record, initialize the necessary public members of TabletManager, and invoke Start.
  • InitTablet and the old Start have been broken out into smaller functions that perform focused and isolated work. All those actions are performed by the new Start function.
  • VREngine and UpdateStream follow the two-phase initialization. They are created outside tm, but the Start function will invoke their InitDBConfig function after computing the db name. They are also optional, which makes it convenient for tests.
  • action_agent.go and init_tablet.go are replaced by tm_init.go.
  • The mysql port is computed by a standalone goroutine that terminates once it's saved it into the tablet record. There are no use cases where the port will change. So, this should only one-time.
  • UpdateStream is always enabled. There was no reason to ever disable it. This is how VStream works, and it's been working fine.
  • A race has been fixed in shard sync where the sync loop may end up trying to close a nil channel.
  • Removed legacy (3.0) code that uses PortMap to store and retrieve the mysql host and port.
  • New unit tests cover all the critical code paths.

sougou added 30 commits June 12, 2020 09:00
mysql host and port have been first class proto fields for a long
time now.

Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
The previous scheme was unnecessarily complex and elaborate.
The new code launches a simple standalone goroutine that
polls and exits after a successful update.

Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
No one knows this exists, and no one uses it. The intuitive tablet
type is the one from init_tablet_type, which everybody already sets
while starting a vttablet.

Because this is the only use case in real life, this change also
requires init_tablet_type to be always specified.

Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
We'll recombine them differently later.

Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Preparing for a struct based initialization.

Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Also fixed a race in shard sync.

Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
@sougou sougou requested review from enisoc and deepthi June 15, 2020 01:25
Copy link
Member

@deepthi deepthi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass review with minor nits

go/cmd/vtbackup/vtbackup.go Show resolved Hide resolved
go/cmd/vttablet/healthz.go Outdated Show resolved Hide resolved
go/cmd/vttablet/vttablet.go Outdated Show resolved Hide resolved
go/cmd/vttablet/vttablet.go Show resolved Hide resolved
go/test/endtoend/reparent/reparent_test.go Show resolved Hide resolved
go/vt/vtctl/vtctl.go Show resolved Hide resolved
Copy link
Member

@deepthi deepthi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good, a few questions/comments.

go/vt/topo/shard.go Show resolved Hide resolved
go/vt/vttablet/tabletmanager/tm_init_test.go Outdated Show resolved Hide resolved
go/vt/vttablet/tabletmanager/tm_init_test.go Show resolved Hide resolved
go/vt/vttablet/tabletmanager/tm_init.go Outdated Show resolved Hide resolved
go/vt/vttablet/tabletmanager/tm_init.go Show resolved Hide resolved
go/vt/vttablet/tabletmanager/shard_sync.go Show resolved Hide resolved
go/vt/vttablet/tabletmanager/shard_sync.go Show resolved Hide resolved
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
@deepthi deepthi merged commit 9ad7303 into vitessio:master Jun 24, 2020
@deepthi deepthi added this to the v7.0 milestone Jul 17, 2020
@sougou sougou deleted the ss-tm-owned-record2 branch July 29, 2020 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants