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

Date conversion bug in _wm_stats #775

Open
martincox opened this issue Dec 22, 2017 · 0 comments
Open

Date conversion bug in _wm_stats #775

martincox opened this issue Dec 22, 2017 · 0 comments

Comments

@martincox
Copy link
Contributor

martincox commented Dec 22, 2017

In riak_repl_wm_stats a UTC datetime is passed into httpd_util:rfc1123/1, which expects a local date. It causes the stats to blow up when clocks go forward for DST. rfc1123 takes a local datetime and throws an exception when you pass a datetime that sits within the mystical non-existent hour when moving clocks forward. It should be handled gracefully, and there's a patch in OTP 20.1 for it. But we should be passing in a local time anyway. The net result is that we lose the ability to monitor for an hour during this time period.

([email protected])1> Seconds = 63657709200. %% riak_core_util:moment() to produce current UTC seconds
63657709200
([email protected])2> Date = calendar:gregorian_seconds_to_datetime(Seconds).
2017,3,26},{1,0,0
([email protected])3> Formatted = httpd_util:rfc1123_date(Date).
exception error: no case clause matching []
in function httpd_util:rfc1123_date/1 (httpd_util.erl, line 344)

Fixed by converting to a local datetime with calendar:universal_time_to_local_time/1:

([email protected])13> Seconds = 63657709200. %% riak_core_util:moment() to produce current UTC seconds
63657709200
([email protected])14> Date = calendar:gregorian_seconds_to_datetime(Seconds).
2017,3,26,1,0,0
([email protected])15> DateLocal = calendar:universal_time_to_local_time(Date).
2017,3,26,2,0,0
([email protected])16> Formatted = httpd_util:rfc1123_date(DateLocal).
"Sun, 26 Mar 2017 01:00:00 GMT"

Think this is the same as described in basho/riak_core#773.

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

No branches or pull requests

1 participant