-
Notifications
You must be signed in to change notification settings - Fork 42
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
Include enums in dbinit_equal_sum_of_all_up
test
#4472
Changes from 1 commit
f731961
d791b67
403e194
fc1d01f
5acc7fc
338828a
9584edf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,7 +191,6 @@ CREATE UNIQUE INDEX IF NOT EXISTS lookup_switch_by_rack ON omicron.public.switch | |
|
||
CREATE TYPE IF NOT EXISTS omicron.public.service_kind AS ENUM ( | ||
'clickhouse', | ||
'clickhouse_keeper', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm sure what I'm about to say is absolutely taboo, but I think we should actually update the migration and not this. The specific update would be an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, that's very cool. I didn't know you could insert it into a particular spot. We might have issues with the order number comparison if we do that. I think when you insert in the middle of two existing members, it's going to give it an decimal order number halfway between them. Then again I think we will also have this problem if we ever delete a variant. Important not-really-edge cases to consider. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It shouldn't be an issue because the enum isn't stored as a decimal. You can find an overview of the format here. Postgres stores enums as floats so you'd There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I’m saying those order numbers won’t match what’s generated from scratch in dbinit.sql, which would be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope! To my surprise, this still passes. I don't think we can change the migrations that have already been applied on customer racks, but I agree the diff --git a/schema/crdb/4.0.0/up1.sql b/schema/crdb/4.0.0/up1.sql
index b26b646d6..ba67d8394 100644
--- a/schema/crdb/4.0.0/up1.sql
+++ b/schema/crdb/4.0.0/up1.sql
@@ -1 +1 @@
-ALTER TYPE omicron.public.service_kind ADD VALUE IF NOT EXISTS 'clickhouse_keeper';
+ALTER TYPE omicron.public.service_kind ADD VALUE IF NOT EXISTS 'clickhouse_keeper' AFTER 'clickhouse';
diff --git a/schema/crdb/4.0.0/up2.sql b/schema/crdb/4.0.0/up2.sql
index 018d39c13..e71cb22f3 100644
--- a/schema/crdb/4.0.0/up2.sql
+++ b/schema/crdb/4.0.0/up2.sql
@@ -1 +1 @@
-ALTER TYPE omicron.public.dataset_kind ADD VALUE IF NOT EXISTS 'clickhouse_keeper';
+ALTER TYPE omicron.public.dataset_kind ADD VALUE IF NOT EXISTS 'clickhouse_keeper' AFTER 'clickhouse';
diff --git a/schema/crdb/dbinit.sql b/schema/crdb/dbinit.sql
index 6e8ab0e39..da842cbfe 100644
--- a/schema/crdb/dbinit.sql
+++ b/schema/crdb/dbinit.sql
@@ -191,6 +191,7 @@ CREATE UNIQUE INDEX IF NOT EXISTS lookup_switch_by_rack ON omicron.public.switch
CREATE TYPE IF NOT EXISTS omicron.public.service_kind AS ENUM (
'clickhouse',
+ 'clickhouse_keeper',
'cockroach',
'crucible',
'crucible_pantry',
@@ -201,7 +202,6 @@ CREATE TYPE IF NOT EXISTS omicron.public.service_kind AS ENUM (
'ntp',
'oximeter',
'tfport',
- 'clickhouse_keeper',
'mgd'
);
@@ -402,9 +402,9 @@ CREATE TYPE IF NOT EXISTS omicron.public.dataset_kind AS ENUM (
'crucible',
'cockroach',
'clickhouse',
+ 'clickhouse_keeper',
'external_dns',
- 'internal_dns',
- 'clickhouse_keeper'
+ 'internal_dns'
);
/* There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we have to leave the migrations as is we should at least comment on why the enum arms are out of order |
||
'cockroach', | ||
'crucible', | ||
'crucible_pantry', | ||
|
@@ -202,6 +201,7 @@ CREATE TYPE IF NOT EXISTS omicron.public.service_kind AS ENUM ( | |
'ntp', | ||
'oximeter', | ||
'tfport', | ||
'clickhouse_keeper', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @zephraph asked the following extremely relevant question:
So there are a few cases we need to consider:
By making this change, we "fix" case (2), but we "break" case (3). I point this out to identify: if you rely on enum order after this change, there are still deployments that exist where we do not have such a guarantee. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All this is to say -- we can make this change, and if you want, but I think it's still unsafe to rely on order of our enums with possible deployments unless we add a "schema change" that validates order. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (also, to be explicit, the changes that you've added to the integration tests are extremely useful still, in either situation) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a pain-in-the-ass, but we could:
This is a "full table scan" operation but the data sizes are really small so I don't think it's so bad There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a minor note... it doesn't have to be at the end. It'll still work being inserted after There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with this approach (even if it makes me slightly nervous b/c we have to do a small amount of data migration). There are two primary justifications that lead me to believe this is a good idea
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I did it in 338828a. Rather than keep See the readme I added for the migration summarizing what it does: https://github.com/oxidecomputer/omicron/blob/338828a24837790f7b96a30dde7aecf7963748d0/schema/crdb/10.0.0/README.md |
||
'mgd' | ||
); | ||
|
||
|
@@ -402,9 +402,9 @@ CREATE TYPE IF NOT EXISTS omicron.public.dataset_kind AS ENUM ( | |
'crucible', | ||
'cockroach', | ||
'clickhouse', | ||
'clickhouse_keeper', | ||
'external_dns', | ||
'internal_dns' | ||
'internal_dns', | ||
'clickhouse_keeper' | ||
); | ||
|
||
/* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to get rid of
Eq
to make this work because floats don't implEq
. Fortunately it seems our equality checks only needPartialEq
anyway.