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

(6/5) Collapse "sled_resource" into "sled_resource_vmm" type #7471

Open
wants to merge 8 commits into
base: affinity-integration
Choose a base branch
from

Conversation

smklein
Copy link
Collaborator

@smklein smklein commented Feb 3, 2025

This specializes the table for VMM usage specifically, rather than leaving it generic for speculative usage by other services.

Comment on lines -975 to -981
// Using the connection we got from the connection pool prior to applying
// the schema migrations, attempt to insert a sled resource. This involves
// the `sled_resource_kind` enum, whose OID was changed by the schema
// migration in version 53.0.0 (by virtue of the enum being dropped and
// added back with a different set of variants). If the diesel OID cache was
// populated when we acquired the connection from the pool, this will fail
// with a `type with ID $NUM does not exist` error.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

IIRC, this was intended to guard against a problematic OID-caching bug. Is it safe to replace this with "any other old enum?"

(this needs to change in this PR because the enum-under-test no longer exists)

Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC it should be possible to use any enum that didn't exist in the first version.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is something I wanted to confirm - tagging @jgallagher , since I think you implemented this originally.

I thought this test needed to check for:

  • Any enum that exists in "version 1" of the schema...
  • Which was modified in a later schema upgrade...
  • ... and which still exists in the most recent schema, so it can be queried?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

mmm it might be even more specific than that - I think this type was actually "dropped" and re-created - so the name is shared between "v1" and "the current version", but the type is wholly distinct

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think instance_auto_restart has also been DROPPED and re-created, but it did not exist in the initial version. I don't think any other enum exists with the same characteristics of:

  • Existed in v1
  • Exists in current revision
  • Was dropped + recreated (so the name is shared, but the OID is altered)

Copy link
Contributor

Choose a reason for hiding this comment

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

mmm it might be even more specific than that - I think this type was actually "dropped" and re-created - so the name is shared between "v1" and "the current version", but the type is wholly distinct

I believe this is correct (this test came out of #5561, for a very large amount of context).

I think instance_auto_restart has also been DROPPED and re-created, but it did not exist in the initial version. I don't think any other enum exists with the same characteristics of: ...

I think you could adjust this test to use instance_auto_restart by tweaking how many schema migrations are applied before we pause and grab a connection. Right now we .take(1), grab a connection, then .skip(1), then use the connection after all migrations are applied. We could change the 1 to whatever migration initially added instance_auto_restart, I believe?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, I've implemented this in fb8976d

I decided to move it into the validate_data_migration test, and to expand the "test context" of that function. We already had hooks for "before/after" schema migrations there, and I figured this made it a little more explicit about "use state from right before update XXX, and then check it later".

I've also added some documentation to hopefully make it easier to find other cases of these enums, in case this data shifts again in the future (which assuredly it will, at some point)

Copy link
Contributor

@andrewjstone andrewjstone left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this @smklein. Much appreciated.

@hawkw hawkw self-requested a review February 4, 2025 17:27
Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

Looks good to me once the stuff about the OID-caching bug test is worked out!

schema/crdb/dbinit.sql Show resolved Hide resolved
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.

4 participants