-
Notifications
You must be signed in to change notification settings - Fork 40
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
dbinit is getting too order dependent #4286
Comments
It seems that there may be some changes in the |
I really tried avoiding order-dependent anonymous names, with: CREATE TABLE IF NOT EXISTS omicron.public.foo (
id UUID CONSTRAINT id_not_null NOT NULL CONSTRAINT foo_pkey PRIMARY KEY
); But this is still producing an anonymously named "NOT NULL" constraint:
|
Admittedly, |
Here's my proposal: When querying the information_schema, we explicitly look for "constraint_name"s where the name ends with "_not_null", and we drop these rows so they don't get compared. These names are internal to CRDB, they're order dependent, and frankly, we don't care what they are. The comparison of I'll get a prototype PR up. |
It's kind of hard to tell from the docs, but it looks like these anonymous constraints are automatically created to satisfy the primary key constraint. The named That all corroborates what you're saying, that these can probably be ignored. Another option would be to use |
I diffed the output of ISTM that the names given to NOT NULL constraints are of the form I agree with the previous couple comments--we should see if we can come up with checks that depend less on CRDB's internal NOT NULL constraint naming scheme. |
I'm going to aim for a first draft that modifies our query for |
#4288 is ready for review - By parsing |
This PR does two things: 1. It avoids checking for the order-dependent NOT NULL constraint in information schema, opting to parse the output of `SHOW CONSTRAINTS` and [information_schema.columna.is_nullable](https://www.cockroachlabs.com/docs/v23.1/information-schema#columns) instead. 2. It re-orders the db_metadata creation to the end of dbinit.sql (mostly for clarity) Fixes #4286
Following up from some issues observed by @internet-diglett -- we're observing that the
dbinit_equals_sum_of_all_up
test is failing more frequently (not flake, just with new PRs) for schema changes which cause constraint changes.This was referenced by @gjcolombo in https://github.com/oxidecomputer/omicron/tree/main/schema/crdb#adding-tables-and-views , but it's reproducible in some surprising cases.
For example, right now, with
main
at ee8d93b , if I add the following:To both
8.0.0/up.sql
, and also to the end ofdbinit.sql
, I see test failures comparing table constraints.The text was updated successfully, but these errors were encountered: