Skip to content

database support for PendingMgsUpdate for SP updates #8291

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

Draft
wants to merge 11 commits into
base: dap/rustfmt-bailout
Choose a base branch
from

Conversation

davepacheco
Copy link
Collaborator

@davepacheco davepacheco commented Jun 6, 2025

This is mostly code-complete, the test is updated, and it appears to work.

Depends on #8394.

TODO:

  • implement schema migration
  • cleanup -- the insertion code is really gross
  • I'd like to implement support for RoT updates too to make sure we're not missing something important that would require an annoying database migration to get past

@davepacheco davepacheco self-assigned this Jun 6, 2025
Comment on lines 461 to 462
// Right now, we only implement support for storing SP updates.
let PendingMgsUpdateDetails::Sp {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit - maybe match here instead of let ... else ...? That way it's obvious which cases aren't implemented yet.

Comment on lines 476 to 477
// XXX-dap size of int
SpMgsSlot::from(SqlU16::from(u16::try_from(update.slot_id).unwrap())).into_sql::<diesel::sql_types::Int4>(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we change PendingMgsUpdate::slot_id to u16 to not have to do this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I need to revisit this. I feel like I looked at this when I was first defining this struct and I picked u32 because some other place provided that. I need to go try that to remember where that was.

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 looked into doing this and decided to split it into two PRs.

  • one to change PendingMgsUpdate::slot_id to u16
  • one to change MGS to expose the slot ids as u16

I'll do these in follow-ons. For now I have added an unwrap() but it will be short-lived (and I've filed #8378 to track it).

.execute_async(&conn)
.await?;
if count != 1 {
// This should be impossible in practice. We will insert
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this what you were referring to in the PR description ("cleanup -- the insertion code is really gross")?

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 was thinking of L471-L485. I believe that code is doing the right thing, but it's pretty gnarly to read. I figured I'd add some comments, extract some of the expressions into named variables, and just edit a bit to see how I can make it more readable.

@davepacheco davepacheco changed the base branch from main to dap/rustfmt-bailout June 19, 2025 16:06
@davepacheco
Copy link
Collaborator Author

The cleanup really wanted a rustfmt pass, but rustfmt hasn't been working on this code path. Fixing that added a bunch of noise so I split that into #8394 and made this PR dependent on that one.

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.

2 participants