-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Pass in cell to EnsureVSchema and GetOrCreateShard #5930
Changes from all commits
e8497f7
2a50906
1724a71
5c29a6b
ca85789
72e75c1
f8edec4
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 |
---|---|---|
|
@@ -49,14 +49,19 @@ func VerifyQueriesUsingVtgate(t *testing.T, session *vtgateconn.VTGateSession, q | |
|
||
func RestoreTablet(t *testing.T, localCluster *cluster.LocalProcessCluster, tablet *cluster.Vttablet, restoreKSName string, shardName string, keyspaceName string, commonTabletArg []string) { | ||
tablet.ValidateTabletRestart(t) | ||
tm := time.Now().UTC() | ||
tm.Format(time.RFC3339) | ||
_, err := localCluster.VtctlProcess.ExecuteCommandWithOutput("CreateKeyspace", | ||
"-keyspace_type=SNAPSHOT", "-base_keyspace="+keyspaceName, | ||
"-snapshot_time", tm.Format(time.RFC3339), restoreKSName) | ||
require.Nil(t, err) | ||
|
||
replicaTabletArgs := commonTabletArg | ||
|
||
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. @zmagg and I discussed this. It seems like this was a flaky test. The following change addresses that problem. |
||
_, err := localCluster.VtctlProcess.ExecuteCommandWithOutput("GetKeyspace", restoreKSName) | ||
|
||
if err != nil { | ||
tm := time.Now().UTC() | ||
tm.Format(time.RFC3339) | ||
_, err := localCluster.VtctlProcess.ExecuteCommandWithOutput("CreateKeyspace", | ||
"-keyspace_type=SNAPSHOT", "-base_keyspace="+keyspaceName, | ||
"-snapshot_time", tm.Format(time.RFC3339), restoreKSName) | ||
require.Nil(t, err) | ||
} | ||
|
||
if UseXb { | ||
replicaTabletArgs = append(replicaTabletArgs, XbArgs...) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,7 +72,7 @@ func (ts *Server) GetVSchema(ctx context.Context, keyspace string) (*vschemapb.K | |
} | ||
|
||
// EnsureVSchema makes sure that a vschema is present for this keyspace or creates a blank one if it is missing | ||
func (ts *Server) EnsureVSchema(ctx context.Context, keyspace string) error { | ||
func (ts *Server) EnsureVSchema(ctx context.Context, keyspace string, cells []string) error { | ||
vschema, err := ts.GetVSchema(ctx, keyspace) | ||
if err != nil && !IsErrType(err, NoNode) { | ||
log.Info("error in getting vschema for keyspace %s: %v", keyspace, err) | ||
|
@@ -89,7 +89,7 @@ func (ts *Server) EnsureVSchema(ctx context.Context, keyspace string) error { | |
} | ||
} | ||
|
||
err = ts.RebuildSrvVSchema(ctx, []string{} /* cells */) | ||
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. What if we change 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. Oh, I like that a lot more. It still does the nice thing for single cell setups, with the benefit of being easier to reason about overall. I'll switch to that approach! That would've been fine. The problem was that the tablet in the init loop wasn't just rebuilding its own cell it was rebuilding all the other cells. |
||
err = ts.RebuildSrvVSchema(ctx, cells) | ||
if err != nil { | ||
log.Errorf("could not rebuild SrvVschema after creating keyspace: %v", err) | ||
return err | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1620,7 +1620,12 @@ func commandCreateKeyspace(ctx context.Context, wr *wrangler.Wrangler, subFlags | |
} | ||
|
||
if !*allowEmptyVSchema { | ||
err = wr.TopoServer().EnsureVSchema(ctx, keyspace) | ||
cells, err := wr.TopoServer().GetKnownCells(ctx) | ||
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. I think we could also just pass an empty cells list to mean "all cells", since |
||
if err != nil { | ||
return fmt.Errorf("GetKnownCells failed: %v", err) | ||
} | ||
|
||
err = wr.TopoServer().EnsureVSchema(ctx, keyspace, cells) | ||
} | ||
|
||
if err != nil { | ||
|
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.
This seems like it should not be removed right?