Skip to content

Mostly switch to chrono #781

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 2 commits into from
Jun 4, 2020
Merged

Mostly switch to chrono #781

merged 2 commits into from
Jun 4, 2020

Conversation

Kixiron
Copy link
Member

@Kixiron Kixiron commented May 28, 2020

Most of the stuff can be switched to chrono, but iron-related timeouts require time and won't be able to be removed until iron is.

@Kixiron
Copy link
Member Author

Kixiron commented May 28, 2020

This is currently kinda broken, but it's caused me so much pain that I'm hoping someone else knows what the hell they're doing

@jyn514
Copy link
Member

jyn514 commented May 29, 2020

This is the relevant error message: https://github.com/rust-lang/docs.rs/runs/718596017#step:11:1876

backtrace
2020-05-28T23:12:12.2894420Z [2020-05-28T23:12:12Z DEBUG cratesfyi::db::add_package] Adding package into database
2020-05-28T23:12:12.3107644Z [2020-05-28T23:12:12Z DEBUG cratesfyi::db::add_package] Adding build into database
2020-05-28T23:12:13.1011236Z thread '<unnamed>' panicked at 'a Display implementation returned an error unexpectedly: Error', /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/liballoc/string.rs:2165:9
2020-05-28T23:12:13.1011570Z stack backtrace:
2020-05-28T23:12:13.1011763Z    0: backtrace::backtrace::libunwind::trace
2020-05-28T23:12:13.1012289Z              at /cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/libunwind.rs:86
2020-05-28T23:12:13.1012461Z    1: backtrace::backtrace::trace_unsynchronized
2020-05-28T23:12:13.1012851Z              at /cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/mod.rs:66
2020-05-28T23:12:13.1013013Z    2: std::sys_common::backtrace::_print_fmt
2020-05-28T23:12:13.1013152Z              at src/libstd/sys_common/backtrace.rs:78
2020-05-28T23:12:13.1013308Z    3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
2020-05-28T23:12:13.1013463Z              at src/libstd/sys_common/backtrace.rs:59
2020-05-28T23:12:13.1013605Z    4: core::fmt::write
2020-05-28T23:12:13.1013737Z              at src/libcore/fmt/mod.rs:1063
2020-05-28T23:12:13.1013857Z    5: std::io::Write::write_fmt
2020-05-28T23:12:13.1013991Z              at src/libstd/io/mod.rs:1426
2020-05-28T23:12:13.1014428Z    6: std::sys_common::backtrace::_print
2020-05-28T23:12:13.1014565Z              at src/libstd/sys_common/backtrace.rs:62
2020-05-28T23:12:13.1014705Z    7: std::sys_common::backtrace::print
2020-05-28T23:12:13.1014845Z              at src/libstd/sys_common/backtrace.rs:49
2020-05-28T23:12:13.1014985Z    8: std::panicking::default_hook::{{closure}}
2020-05-28T23:12:13.1015109Z              at src/libstd/panicking.rs:204
2020-05-28T23:12:13.1015245Z    9: std::panicking::default_hook
2020-05-28T23:12:13.1015380Z              at src/libstd/panicking.rs:224
2020-05-28T23:12:13.1015515Z   10: std::panicking::rust_panic_with_hook
2020-05-28T23:12:13.1015649Z              at src/libstd/panicking.rs:470
2020-05-28T23:12:13.1015781Z   11: rust_begin_unwind
2020-05-28T23:12:13.1015911Z              at src/libstd/panicking.rs:378
2020-05-28T23:12:13.1016037Z   12: core::panicking::panic_fmt
2020-05-28T23:12:13.1016170Z              at src/libcore/panicking.rs:85
2020-05-28T23:12:13.1016312Z   13: core::option::expect_none_failed
2020-05-28T23:12:13.1016446Z              at src/libcore/option.rs:1211
2020-05-28T23:12:13.1016582Z   14: core::result::Result<T,E>::expect
2020-05-28T23:12:13.1016822Z              at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libcore/result.rs:961
2020-05-28T23:12:13.1016985Z   15: <T as alloc::string::ToString>::to_string
2020-05-28T23:12:13.1017138Z              at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/liballoc/string.rs:2165
2020-05-28T23:12:13.1017287Z   16: <cratesfyi::web::releases::Release as serde::ser::Serialize>::serialize
2020-05-28T23:12:13.1017437Z              at src/web/releases.rs:61
2020-05-28T23:12:13.1017582Z   17: serde::ser::impls::<impl serde::ser::Serialize for &T>::serialize
2020-05-28T23:12:13.1018038Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/serde-1.0.110/src/ser/impls.rs:390
2020-05-28T23:12:13.1018211Z   18: serde::ser::impls::<impl serde::ser::Serialize for &T>::serialize
2020-05-28T23:12:13.1018638Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/serde-1.0.110/src/ser/impls.rs:390
2020-05-28T23:12:13.1018811Z   19: serde::ser::impls::<impl serde::ser::Serialize for &T>::serialize
2020-05-28T23:12:13.1019227Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/serde-1.0.110/src/ser/impls.rs:390
2020-05-28T23:12:13.1019384Z   20: serde_json::value::to_value
2020-05-28T23:12:13.1019779Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/serde_json-1.0.53/src/value/mod.rs:964
2020-05-28T23:12:13.1019961Z   21: <serde_json::value::ser::SerializeVec as serde::ser::SerializeSeq>::serialize_element
2020-05-28T23:12:13.1020384Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/serde_json-1.0.53/src/value/ser.rs:313
2020-05-28T23:12:13.1020548Z   22: serde::ser::Serializer::collect_seq
2020-05-28T23:12:13.1020951Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/serde-1.0.110/src/ser/mod.rs:1283
2020-05-28T23:12:13.1021134Z   23: serde::ser::impls::<impl serde::ser::Serialize for alloc::vec::Vec<T>>::serialize
2020-05-28T23:12:13.1021556Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/serde-1.0.110/src/ser/impls.rs:198
2020-05-28T23:12:13.1021725Z   24: serde::ser::impls::<impl serde::ser::Serialize for &T>::serialize
2020-05-28T23:12:13.1022133Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/serde-1.0.110/src/ser/impls.rs:390
2020-05-28T23:12:13.1022297Z   25: serde::ser::impls::<impl serde::ser::Serialize for &T>::serialize
2020-05-28T23:12:13.1022689Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/serde-1.0.110/src/ser/impls.rs:390
2020-05-28T23:12:13.1022849Z   26: serde_json::value::to_value
2020-05-28T23:12:13.1023252Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/serde_json-1.0.53/src/value/mod.rs:964
2020-05-28T23:12:13.1023508Z   27: <serde_json::value::ser::SerializeMap as serde::ser::SerializeMap>::serialize_value
2020-05-28T23:12:13.1023948Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/serde_json-1.0.53/src/value/ser.rs:410
2020-05-28T23:12:13.1024115Z   28: serde::ser::SerializeMap::serialize_entry
2020-05-28T23:12:13.1024522Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/serde-1.0.110/src/ser/mod.rs:1823
2020-05-28T23:12:13.1024704Z   29: <serde_json::value::ser::SerializeMap as serde::ser::SerializeStruct>::serialize_field
2020-05-28T23:12:13.1025132Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/serde_json-1.0.53/src/value/ser.rs:622
2020-05-28T23:12:13.1025298Z   30: <cratesfyi::web::page::Page<T> as serde::ser::Serialize>::serialize
2020-05-28T23:12:13.1025429Z              at src/web/page.rs:135
2020-05-28T23:12:13.1025577Z   31: serde::ser::impls::<impl serde::ser::Serialize for &T>::serialize
2020-05-28T23:12:13.1025986Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/serde-1.0.110/src/ser/impls.rs:390
2020-05-28T23:12:13.1026147Z   32: serde_json::value::to_value
2020-05-28T23:12:13.1026616Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/serde_json-1.0.53/src/value/mod.rs:964
2020-05-28T23:12:13.1026784Z   33: handlebars::context::to_json
2020-05-28T23:12:13.1027204Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/handlebars-0.29.1/src/context.rs:209
2020-05-28T23:12:13.1027773Z   34: handlebars_iron::middleware::Template::new
2020-05-28T23:12:13.1028566Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/handlebars-iron-0.25.2/src/middleware.rs:29
2020-05-28T23:12:13.1028922Z   35: cratesfyi::web::page::Page<T>::to_resp
2020-05-28T23:12:13.1029204Z              at src/web/page.rs:107
2020-05-28T23:12:13.1029499Z   36: cratesfyi::web::releases::releases_handler
2020-05-28T23:12:13.1029790Z              at src/web/releases.rs:376
2020-05-28T23:12:13.1030096Z   37: cratesfyi::web::releases::recent_releases_handler
2020-05-28T23:12:13.1030391Z              at src/web/releases.rs:398
2020-05-28T23:12:13.1030685Z   38: core::ops::function::Fn::call
2020-05-28T23:12:13.1030989Z              at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libcore/ops/function.rs:72
2020-05-28T23:12:13.1031298Z   39: <F as iron::middleware::Handler>::handle
2020-05-28T23:12:13.1031845Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/iron-0.5.1/src/middleware/mod.rs:312
2020-05-28T23:12:13.1032187Z   40: <alloc::boxed::Box<dyn iron::middleware::Handler> as iron::middleware::Handler>::handle
2020-05-28T23:12:13.1032737Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/iron-0.5.1/src/middleware/mod.rs:318
2020-05-28T23:12:13.1033742Z   41: <cratesfyi::web::metrics::RequestRecorder as iron::middleware::Handler>::handle
2020-05-28T23:12:13.1034015Z              at src/web/metrics.rs:182
2020-05-28T23:12:13.1034276Z   42: <alloc::boxed::Box<dyn iron::middleware::Handler> as iron::middleware::Handler>::handle
2020-05-28T23:12:13.1035341Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/iron-0.5.1/src/middleware/mod.rs:318
2020-05-28T23:12:13.1035639Z   43: <alloc::boxed::Box<dyn iron::middleware::Handler> as iron::middleware::Handler>::handle
2020-05-28T23:12:13.1036126Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/iron-0.5.1/src/middleware/mod.rs:318
2020-05-28T23:12:13.1036393Z   44: router::router::Router::handle_method
2020-05-28T23:12:13.1036854Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/router-0.5.1/src/router.rs:199
2020-05-28T23:12:13.1037120Z   45: <router::router::Router as iron::middleware::Handler>::handle
2020-05-28T23:12:13.1037588Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/router-0.5.1/src/router.rs:212
2020-05-28T23:12:13.1037858Z   46: <alloc::boxed::Box<dyn iron::middleware::Handler> as iron::middleware::Handler>::handle
2020-05-28T23:12:13.1038476Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/iron-0.5.1/src/middleware/mod.rs:318
2020-05-28T23:12:13.1038744Z   47: iron::middleware::Chain::continue_from_handler
2020-05-28T23:12:13.1039215Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/iron-0.5.1/src/middleware/mod.rs:282
2020-05-28T23:12:13.1039478Z   48: iron::middleware::Chain::continue_from_before
2020-05-28T23:12:13.1039945Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/iron-0.5.1/src/middleware/mod.rs:276
2020-05-28T23:12:13.1043149Z   49: <iron::middleware::Chain as iron::middleware::Handler>::handle
2020-05-28T23:12:13.1043861Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/iron-0.5.1/src/middleware/mod.rs:200
2020-05-28T23:12:13.1044145Z   50: <alloc::boxed::Box<dyn iron::middleware::Handler> as iron::middleware::Handler>::handle
2020-05-28T23:12:13.1044633Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/iron-0.5.1/src/middleware/mod.rs:318
2020-05-28T23:12:13.1045045Z   51: <cratesfyi::web::CratesfyiHandler as iron::middleware::Handler>::handle::{{closure}}
2020-05-28T23:12:13.1045298Z              at src/web/mod.rs:145
2020-05-28T23:12:13.1045530Z   52: core::result::Result<T,E>::or_else
2020-05-28T23:12:13.1045769Z              at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libcore/result.rs:797
2020-05-28T23:12:13.1046623Z   53: <cratesfyi::web::CratesfyiHandler as iron::middleware::Handler>::handle
2020-05-28T23:12:13.1046872Z              at src/web/mod.rs:143
2020-05-28T23:12:13.1047322Z   54: <iron::iron::RawHandler<H> as hyper::server::Handler>::handle
2020-05-28T23:12:13.1047848Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/iron-0.5.1/src/iron.rs:176
2020-05-28T23:12:13.1048108Z   55: hyper::server::Worker<H>::keep_alive_loop
2020-05-28T23:12:13.1048588Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/hyper-0.10.16/src/server/mod.rs:340
2020-05-28T23:12:13.1048849Z   56: hyper::server::Worker<H>::handle_connection
2020-05-28T23:12:13.1049329Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/hyper-0.10.16/src/server/mod.rs:282
2020-05-28T23:12:13.1049590Z   57: hyper::server::handle::{{closure}}
2020-05-28T23:12:13.1050049Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/hyper-0.10.16/src/server/mod.rs:242
2020-05-28T23:12:13.1050314Z   58: hyper::server::listener::spawn_with::{{closure}}
2020-05-28T23:12:13.1050789Z              at /home/runner/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/hyper-0.10.16/src/server/listener.rs:50
2020-05-28T23:12:13.1051057Z note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@jyn514
Copy link
Member

jyn514 commented May 29, 2020

Looks like the impl Display for Release returned an error.

@Kixiron
Copy link
Member Author

Kixiron commented May 29, 2020

My favorite error, Error! I’ll take a stab tomorrow

@Nemo157
Copy link
Member

Nemo157 commented May 29, 2020

Using Local seems wrong, nothing should care about what the timezone of the server is (except maybe the "cronjobs", though I think making them UTC based as well would make sense).

@Kixiron
Copy link
Member Author

Kixiron commented May 29, 2020

While I agree that using UTC would be preferable, it requires changing every row of the DB that uses TIMESTAMP to use TIMESTAMPZ which I don't really know how to do. The rationale behind using Local was to match the previous behavior as closely as possible

@Nemo157
Copy link
Member

Nemo157 commented May 29, 2020

The database is already using timestamp without time zone correctly (so that it will not do any translation of time input/output and just return them as is), I assume there's just weirdness happening currently if you are running in non-UTC, but I couldn't see any way to view timestamps in the UI to confirm.

@Kixiron
Copy link
Member Author

Kixiron commented May 29, 2020

The only place I know of to view timestamps is on builds, and you can't serialize a DateTime<_> from our current DB, only a NiaveDateTime since DateTimes have timezones and NaiveDateTime doesn't

@Kixiron Kixiron force-pushed the chrono branch 2 times, most recently from 9febf27 to 8a9282d Compare May 31, 2020 02:33
Copy link
Member

@Nemo157 Nemo157 left a comment

Choose a reason for hiding this comment

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

LGTM with one more thing that could be changed.

Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

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

Can you summarize why we're making this change, including the benefits and drawbacks compared to time?

"build_time",
&time::at(self.build_time).rfc3339().to_string(),
)?;
state.serialize_field("build_time", &self.build_time.format("%+").to_string())?;
Copy link
Member

Choose a reason for hiding this comment

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

What does %+ mean? Can you add that as a comment?

Copy link
Member Author

Choose a reason for hiding this comment

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

%+ just means a RFC 3339 timestamp, it's in the chrono docs

Copy link
Member

Choose a reason for hiding this comment

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

Let's add a comment anyway in case the docs or behavior ever change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, funnily enough it'll be completely irrelevant once tera finishes, there's no longer a need for a custom serialization routine, but I'll comment it anyways

@Kixiron
Copy link
Member Author

Kixiron commented Jun 1, 2020

The reason we're moving to chrono is that it's newer, more widely used and the successor to time. Chrono gives a lot of flexibility and has good docs, it's an overall bonus

@jyn514 jyn514 merged commit bdaf33b into rust-lang:master Jun 4, 2020
@Kixiron Kixiron deleted the chrono branch June 4, 2020 19:08
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.

3 participants