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

InitTablet should not update master alias on shard record #5316

Merged

Conversation

deepthi
Copy link
Member

@deepthi deepthi commented Oct 16, 2019

NOTE: This PR is targeting the reparent-refactor feature branch, not master.

  • vtctl InitTablet should not update shard's masterAlias. That will be done by the master tablet.
  • store masterTermStartTime on tablet record.

Signed-off-by: deepthi deepthi@planetscale.com

@deepthi deepthi requested a review from sougou as a code owner October 16, 2019 23:33
@deepthi deepthi requested a review from enisoc October 16, 2019 23:33
go/vt/wrangler/shard.go Outdated Show resolved Hide resolved
@deepthi deepthi changed the title InitTablet should set MasterTermStartTime on shard record along with MasterAlias WIP: InitTablet should not update master alias on shard record Oct 18, 2019
…update shard master

Signed-off-by: deepthi <deepthi@planetscale.com>
…arting with InitTablet

Signed-off-by: deepthi <deepthi@planetscale.com>
applicable conditions
vttablet InitTablet should check MasterTermStartTime and take over if
necessary
fix unit test setup to work with changes to InitTablet functions

Signed-off-by: deepthi <deepthi@planetscale.com>
@deepthi deepthi force-pushed the ds-init-tablet-master-ts branch from 2a2e630 to 67d2921 Compare October 22, 2019 19:28
@deepthi deepthi changed the title WIP: InitTablet should not update master alias on shard record InitTablet should not update master alias on shard record Oct 22, 2019
go/vt/wrangler/tablet.go Outdated Show resolved Hide resolved
go/vt/wrangler/tablet.go Outdated Show resolved Hide resolved
…n-zero

Signed-off-by: deepthi <deepthi@planetscale.com>
proto/topodata.proto Outdated Show resolved Hide resolved
go/vt/vttablet/tabletmanager/action_agent.go Outdated Show resolved Hide resolved
go/vt/vttablet/tabletmanager/init_tablet.go Outdated Show resolved Hide resolved
go/vt/vttablet/tabletmanager/init_tablet.go Outdated Show resolved Hide resolved
go/vt/vttablet/tabletmanager/rpc_actions.go Outdated Show resolved Hide resolved
go/vt/wrangler/tablet.go Outdated Show resolved Hide resolved
go/vt/wrangler/tablet.go Outdated Show resolved Hide resolved
go/vt/wrangler/testlib/init_shard_master_test.go Outdated Show resolved Hide resolved
@@ -155,7 +184,8 @@ func TestInitMasterShardChecks(t *testing.T) {
// (master2 needs to run InitTablet with -force, as it is the second
// master in the same shard)
master2 := NewFakeTablet(t, wr, "cell1", 1, topodatapb.TabletType_MASTER, db, ForceInitTablet())
if err := wr.InitShardMaster(ctx, master2.Tablet.Keyspace, master2.Tablet.Shard, master2.Tablet.Alias, false /*force*/, 10*time.Second); err == nil || !strings.Contains(err.Error(), "is not the only master in the shard") {

if err := wr.InitShardMaster(ctx, master2.Tablet.Keyspace, master2.Tablet.Shard, master2.Tablet.Alias, false /*force*/, 10*time.Second); err == nil || !strings.Contains(err.Error(), "is not the shard master") {
Copy link
Member

Choose a reason for hiding this comment

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

Why did this error change just now? I would have thought this test would have broken back when we made false masters demote themselves.

Copy link
Member Author

Choose a reason for hiding this comment

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

ShardSync doesn't run until we start the tablet. So this test didn't change when that was implemented.
Now that we have changed InitTablet to not set MasterAlias on the shard, that value is nil, so the error has changed.

Copy link
Member

Choose a reason for hiding this comment

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

I'm still worried this test is now no longer testing what it was meant to (detecting 2 masters in ISM). I think to keep the test an accurate simulation of 2 masters, we'd need to force the shard record to match one of the masters so ISM reaches the code that checks for 2 masters.

With that said, it may not be worth the effort to truly fix this test because 2 masters should not happen anymore anyway, and before long we want to do a whole overhaul of ISM. WDYT?

go/vt/wrangler/testlib/init_shard_master_test.go Outdated Show resolved Hide resolved
Signed-off-by: deepthi <deepthi@planetscale.com>
Signed-off-by: deepthi <deepthi@planetscale.com>
Signed-off-by: deepthi <deepthi@planetscale.com>
Signed-off-by: deepthi <deepthi@planetscale.com>
@deepthi deepthi force-pushed the ds-init-tablet-master-ts branch from 09e9f8b to f2b8269 Compare October 25, 2019 01:30
go/vt/topotools/tablet.go Outdated Show resolved Hide resolved
go/vt/topotools/tablet.go Outdated Show resolved Hide resolved
go/vt/topotools/tablet.go Outdated Show resolved Hide resolved
@@ -155,7 +184,8 @@ func TestInitMasterShardChecks(t *testing.T) {
// (master2 needs to run InitTablet with -force, as it is the second
// master in the same shard)
master2 := NewFakeTablet(t, wr, "cell1", 1, topodatapb.TabletType_MASTER, db, ForceInitTablet())
if err := wr.InitShardMaster(ctx, master2.Tablet.Keyspace, master2.Tablet.Shard, master2.Tablet.Alias, false /*force*/, 10*time.Second); err == nil || !strings.Contains(err.Error(), "is not the only master in the shard") {

if err := wr.InitShardMaster(ctx, master2.Tablet.Keyspace, master2.Tablet.Shard, master2.Tablet.Alias, false /*force*/, 10*time.Second); err == nil || !strings.Contains(err.Error(), "is not the shard master") {
Copy link
Member

Choose a reason for hiding this comment

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

I'm still worried this test is now no longer testing what it was meant to (detecting 2 masters in ISM). I think to keep the test an accurate simulation of 2 masters, we'd need to force the shard record to match one of the masters so ISM reaches the code that checks for 2 masters.

With that said, it may not be worth the effort to truly fix this test because 2 masters should not happen anymore anyway, and before long we want to do a whole overhaul of ISM. WDYT?

…that new tablet is returned only if there is no error

Signed-off-by: deepthi <deepthi@planetscale.com>
Copy link
Member

@enisoc enisoc left a comment

Choose a reason for hiding this comment

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

LGTM

@deepthi deepthi merged commit d9fa8cd into vitessio:reparent-refactor Oct 25, 2019
@deepthi deepthi deleted the ds-init-tablet-master-ts branch October 25, 2019 23:11
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.

3 participants