Skip to content

Watching Vschema#1624

Merged
alainjobart merged 4 commits into
vitessio:masterfrom
alainjobart:vschema
Apr 6, 2016
Merged

Watching Vschema#1624
alainjobart merged 4 commits into
vitessio:masterfrom
alainjobart:vschema

Conversation

@alainjobart
Copy link
Copy Markdown
Contributor

@sougou I think this works, let me know what you think. Note the WatchVSchema implementations are just cut&paste of the WatchSrvKeyspace implementation.

(internal bug b/27241639 )


This change is Reviewable

Comment thread go/vt/vtgate/planner.go
mu.Lock()
defer mu.Unlock()
formal.Keyspaces[keyspace] = kformal
vschema, err := vindexes.BuildVSchema(formal)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The downside of not re-reading everything is that we won't handle keyspace deletes correctly. I'm guessing it's not a big deal since it's pretty rare. Will it work as expected if a new keyspace was added?

@sougou
Copy link
Copy Markdown
Contributor

sougou commented Apr 6, 2016

LGTM

Approved with PullApprove

@alainjobart
Copy link
Copy Markdown
Contributor Author

@sougou PTAL at extra commit to clear plan cache on reload. Not sure how to unit test that...

And unit tests, implementing it for etcd and zk.
One caveat: if the list of keyspaces changes, vtgate won't notice.
That way each implementation doesn't have to do it.
Comment thread go/vt/vtgate/planner.go
plr.mu.Lock()
plr.vschema = vschema
plr.mu.Unlock()
plr.plans.Clear()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: The clear should happen inside the lock.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually, I think it's more complicated. Let's go with this for now. We'll probably need a more elaborate scheme to prevent race conditions here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree, it's more complicated. With this, there can be plans built with the new vschema, that get flushed for nothing, but that's it. I didn't want to double-lock, then we have to guarantee ordering and such.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's still possible that a builder starts using the old vschema, and we update and clear the plan cache, and then the built plan (based on the older vschema) gets added to the cache. This is because we don't hold the lock on vschema while building the plan. Some brainstorming will be needed.

@sougou
Copy link
Copy Markdown
Contributor

sougou commented Apr 6, 2016

LGTM. One nit.

Approved with PullApprove

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