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

Schema tracking in vtgate #8074

Merged
merged 34 commits into from
Jun 1, 2021
Merged

Conversation

harshit-gangal
Copy link
Member

@harshit-gangal harshit-gangal commented May 7, 2021

Description

This adds a schema tracker that will update the vschema with schema information about tables and columns, fetched from the underlying MySQL instance.

Related Issue(s)

#7995
#7994

Checklist

  • Tests were added or are not required
  • Documentation was added or is not required

@systay systay added Component: Query Serving Type: Enhancement Logical improvement (somewhere between a bug and feature) labels May 9, 2021
harshit-gangal and others added 5 commits May 24, 2021 10:17
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
harshit-gangal and others added 15 commits May 24, 2021 12:13
…vtopo.Server directly

Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
…rom schema tracker

Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
…ema.Tracker

Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Co-authored-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
…chema when errors

Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
frouioui and others added 3 commits May 28, 2021 11:07
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
frouioui and others added 6 commits May 28, 2021 14:53
Co-authored-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Co-authored-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
…tgate

Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
@harshit-gangal harshit-gangal marked this pull request as ready for review June 1, 2021 05:42
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
go/test/endtoend/cluster/cluster_util.go Show resolved Hide resolved
Comment on lines +106 to +114
clusterInstance.VtTabletExtraArgs = []string{"-queryserver-config-schema-change-signal"}
err = clusterInstance.StartUnshardedKeyspace(*keyspace, 1, false)
require.NoError(t, err)

// teardown vttablets
for _, vttablet := range clusterInstance.Keyspaces[0].Shards[0].Vttablets {
err = vttablet.VttabletProcess.TearDown()
require.NoError(t, err)
}
Copy link
Member Author

Choose a reason for hiding this comment

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

instead of starting tablets and shutting them down, we can test this by just creating the keyspace and shard in topo by calling vtctld APIs (CreateKeyspace and CreateShard). That will mimic the same behavior.

go/vt/vtgate/schema/tracker.go Show resolved Hide resolved
go/vt/vtgate/schema/tracker.go Show resolved Hide resolved
Comment on lines +161 to +165
if v == nil {
// We encountered an error, we should always have a current vschema
log.Warning("got a schema changed signal with no loaded vschema. if this persist, something is wrong")
vschema, _ = vindexes.BuildVSchema(&vschemapb.SrvVSchema{})
} else {
Copy link
Member Author

Choose a reason for hiding this comment

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

if currentSrvSchema is nil we do not need to rebuild the VSchema as the empty VSchema would have been published to the subscriber through VSchemaUpdate

This should only be done in the case when we are using updated schema to enhance the VSchema

go/vt/vtgate/vtgate.go Show resolved Hide resolved
Comment on lines +1160 to +1162
if vschema != nil {
e.vschema = vschema
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This can create an issue when a user wants to explicitly clear out the VSchema.
This check will ignore the update and will keep the old version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Query Serving Type: Enhancement Logical improvement (somewhere between a bug and feature)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants