Skip to content

Update rust version to 1.77, chrono to 0.4.35 #26273

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

Merged
merged 1 commit into from
Mar 29, 2024

Conversation

rjobanp
Copy link
Contributor

@rjobanp rjobanp commented Mar 26, 2024

Motivation

A recent update to https://github.com/MaterializeInc/rust-postgres/ uses new chrono features and upgrades the version of rust to 1.77. That update of rust-postgres is needed in #26186 so I decided to go ahead and update the version for MZ.

The majority of the changes are due to the deprecations of many timestamp methods on chrono::NaiveDateTime -- see https://github.com/chronotope/chrono/releases/tag/v0.4.35 for details.

Tips for reviewer

Checklist

  • This PR has adequate test coverage / QA involvement has been duly considered.
  • This PR has an associated up-to-date design doc, is a design doc (template), or is sufficiently small to not require a design.
  • If this PR evolves an existing $T ⇔ Proto$T mapping (possibly in a backwards-incompatible way), then it is tagged with a T-proto label.
  • If this PR will require changes to cloud orchestration or tests, there is a companion cloud PR to account for those changes that is tagged with the release-blocker label (example).
  • This PR includes the following user-facing behavior changes:

@rjobanp rjobanp requested a review from a team as a code owner March 26, 2024 16:10
@rjobanp rjobanp requested a review from a team March 26, 2024 16:10
@rjobanp rjobanp requested a review from a team as a code owner March 26, 2024 16:10
@rjobanp rjobanp requested a review from a team March 26, 2024 16:10
@rjobanp rjobanp requested review from aalexandrov, a team and benesch as code owners March 26, 2024 16:10
@rjobanp rjobanp requested a review from jkosh44 March 26, 2024 16:10
Copy link
Contributor

@jkosh44 jkosh44 left a comment

Choose a reason for hiding this comment

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

Adapter changes LGTM

Copy link
Contributor

@teskje teskje left a comment

Choose a reason for hiding this comment

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

Compute changes look good, but I don't think SinkToken should be marked as dead code.

@rjobanp rjobanp force-pushed the rust-77 branch 13 times, most recently from 1739b49 to 7cd47f0 Compare March 28, 2024 19:59
@rjobanp
Copy link
Contributor Author

rjobanp commented Mar 28, 2024

I just fixed what appears to be the last test failure (just kicked off another full re-run), if anyone wants to be a hero and do a final review/approval

Copy link
Contributor

@ParkMyCar ParkMyCar 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 making this change!

Would love to get this merged soon because AFAICT if you add a new crate dependency Cargo.lock will get updated to the lastest commit of our fork and we'll fail to build MZ

Comment on lines +433 to +442
# parse the package name from a package_id that looks like one of:
# git+https://github.com/MaterializeInc/rust-server-sdk#launchdarkly-server-sdk@1.0.0
# path+file:///Users/roshan/materialize/src/catalog#mz-catalog@0.0.0
# registry+https://github.com/rust-lang/crates.io-index#num-rational@0.4.0
# file:///path/to/my-package#0.1.0
package_id = message["package_id"]
if "@" in package_id:
package = package_id.split("@")[0].split("#")[-1]
else:
package = message["package_id"].split("#")[0].split("/")[-1]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this change required? Maybe the upgrade to Rust 1.77 changed output of cargo build?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes the spec of package-id was updated in the json output: rust-lang/cargo#13311

took a while to figure this out.

@@ -300,7 +300,7 @@ pub(crate) struct ActiveComputeState<'a, A: Allocate> {
}

/// A token that keeps a sink alive.
pub struct SinkToken(Box<dyn Any>);
pub struct SinkToken(#[allow(dead_code)] Box<dyn Any>);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub struct SinkToken(#[allow(dead_code)] Box<dyn Any>);
pub struct SinkToken {
_guard: Box<dyn Any>,
}

This and the other sites triggering "dead code" warning are because the inner fields aren't technically read, we just rely on their Drop impls getting called. If you make this a named field it should remove the need for #[allow(dead_code)]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that'll be cleaner! Discussed offline with @ParkMyCar -- will address these in a follow up PR to get this update in asap since it'll take some time to update all instantiations of the relevant structs

@@ -222,7 +222,7 @@ impl AvroDecode for RowDecoder {

// Get around orphan rule
#[derive(Debug)]
pub(super) struct RowWrapper(pub Row);
pub(super) struct RowWrapper(#[allow(dead_code)] pub Row);
Copy link
Contributor

Choose a reason for hiding this comment

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

Row doesn't seem to be a guard here, but I'm not sure if we ever actually read from the created Row? Could you leave a comment here explaining that this might not actually be dead?

Comment on lines +66 to +69
/// 5874897-12-31, chrono is limited to December 31, 262142, which we mirror
/// here so we can use chrono's formatting methods and have guaranteed safe
/// conversions.
pub const HIGH_DAYS: i32 = 95_015_644;
pub const HIGH_DAYS: i32 = 95_015_279;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a little scary because a date could exist in MZ today that is after the new limit, do you know what would happen in this case? probably a panic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes unfortunately a panic will likely occur if a date of this value already exists. I mentioned to @benesch yesterday, I'm hopeful that since the max limit was defined by chrono and not by postgres, it's unlikely that any of our customers used it as some sort of notional timestamp maximum

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense!

@rjobanp rjobanp merged commit bb22508 into MaterializeInc:main Mar 29, 2024
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.

5 participants