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
@systay systay force-pushed the schema-tracking-vtgate branch from 5c1c251 to 9f7a7ff Compare May 21, 2021 06:20
@harshit-gangal harshit-gangal force-pushed the schema-tracking-vtgate branch from 8e6f5a3 to 410cd4c Compare May 24, 2021 04:48
Signed-off-by: Harshit Gangal <[email protected]>
@harshit-gangal harshit-gangal force-pushed the schema-tracking-vtgate branch from 36a4841 to 31294da Compare May 24, 2021 05:30
harshit-gangal and others added 15 commits May 24, 2021 12:13
Signed-off-by: Andres Taylor <[email protected]>
Co-authored-by: Andres Taylor <[email protected]>
Signed-off-by: Florent Poinsard <[email protected]>
@systay systay force-pushed the schema-tracking-vtgate branch from 0c52ebe to 3c11a1c Compare May 27, 2021 07:33
frouioui and others added 3 commits May 28, 2021 11:07
@systay systay force-pushed the schema-tracking-vtgate branch from 7cada71 to 369ad4a Compare May 28, 2021 11:24
@harshit-gangal harshit-gangal marked this pull request as ready for review June 1, 2021 05:42
Signed-off-by: Florent Poinsard <[email protected]>
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.

@systay systay merged commit a7e87f6 into vitessio:master Jun 1, 2021
@systay systay deleted the schema-tracking-vtgate branch June 1, 2021 12:19
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.

3 participants