-
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
Feature Request: Add support for foreign key mode managed
to vttestserver
#14495
Comments
Learning a bit more now, so this is a bit more involved probably: From https://github.com/vitessio/vitess/releases/tag/v18.0.0:
and
And vttestserver is currently using vitess/docker/vttestserver/run.sh Line 40 in 225fc70
So we'll need to figure out how to replace the VTGate config with a VSchema field, that can still be configured via an environment variable. |
Digging further, I think the challenge is deeper and vttest is involved: vitess/go/vt/vttest/local_cluster.go Lines 138 to 139 in 225fc70
Probably that is then handed further down even. |
(Related question: Is there a way to output the configured value of the new ForeignKeyMode via a SQL query?) |
@janpio Like you said,
So, all you need to do is add a vschema.json file in the directory of your keyspace and specify the For reference as to what the vschema should look like, you can see what we are using in our tests at https://github.com/vitessio/vitess/blob/main/go/test/endtoend/vtgate/foreignkey/unsharded_vschema.json. I am closing this issue, because there doesn't seem to be any change required on our end. Please reopen if you have follow up questions. |
Thanks for the response, I could not connect these dots as I do not know enough about vschema and so on, it seems. My investigation into this: In the vttestserver Docker container we are using this path seems to be hardcoded via The subfolders for the keyspaces seem to be created automatically on startup via this script, and a vitess/docker/vttestserver/setup_vschema_folder.sh Lines 49 to 59 in 225fc70
I guess I will try to access that directory and its subfolders, and put a How can I best confirm this worked? Is there a query I can run to confirm that the configuration was picked up? I sense trouble though, as our Docker container setup mentions that the keyspace config from their is not actually used:
Our tests create a lot of databases dynamically during testing, to get isolation between the different test cases. |
Ok, took me a bit to wrap my head around how to get the
And having a
That starts successfully. But how can I confirm that the keyspace indeed is running with (Setting |
@janpio Yes! Great! You figured out how to specify the Vschema file. I should have probably listed the steps the first time around itself.
The only way to know that the foreign key mode is managed by Vitess is to just check the VSchema that the The purpose of the managed mode is that Vitess does the cascades, but the final result should be indistinguishable from the case where the foreign keys were just allowed. So I don't think there are any queries that you can run to distinguish the two cases.
This is probably the best test you could have run for now 😆 @harshit-gangal Should we add a query that allows users to know which foreign key mode they are in? |
@janpio I have made a PR that adds a new query like If you don't add a Vschema and are running with |
Thanks, the query you have proposed to add seems like the perfect solution. The one still open questio, is if |
You'll have to add vschema for all the databases you create before hand. I don't think there is any other way. |
Ok, I see |
Feature Description
v18 added
Experimental Foreign Key Support
, via themanaged
mode:Unfortunately that does not seem to be supported in vttestserver yet. From the CLI output:
And the docker container script:
vitess/docker/vttestserver/run.sh
Line 40 in 225fc70
It would be great if this would be expended to also support the new experimental
managed
mode.Use Case(s)
We are using
vttestserver
at Prisma to run tests that pretend to be PlanetScale like:https://github.com/prisma/prisma/blob/8fdb2bcb5b2944d9f4b6dd1a9efa20c88f0b5ab4/docker/docker-compose.yml#L77-L94
Note that we use
FOREIGN_KEY_MODE: 'disallow'
right now, and of course want to tomanaged
soon.The text was updated successfully, but these errors were encountered: