Use EXTRACT(EPOCH) when calculating durations
What does this MR do and why?
Note: the bug is not visible to end-users because the aggregated VSA feature is not released yet. The FF is enabled for gitlab-org
group.
This MR fixes a configuration issue that only happens on PRD. The symptoms are described in the issue: #346761 (closed)
How to see the box:
- Go to VSA
- See the time column.
- Click the "issue" button a few times.
- At some point you should see different values (0) for the same rows.
Why does this happening?
It looks like the interval_style
config is misconfigured on some of our replicas:
[ gprd ] production> 10.times { puts ActiveRecord::Base.connection.execute("show intervalstyle").to_a }
{"IntervalStyle"=>"iso_8601"}
{"IntervalStyle"=>"iso_8601"}
{"IntervalStyle"=>"iso_8601"}
{"IntervalStyle"=>"postgres"}
{"IntervalStyle"=>"iso_8601"}
{"IntervalStyle"=>"postgres"}
{"IntervalStyle"=>"postgres"}
{"IntervalStyle"=>"iso_8601"}
{"IntervalStyle"=>"iso_8601"}
{"IntervalStyle"=>"postgres"}
How to fix it?
I notified the DB team about the misconfiguration. This MR fixes the queries to use EXTRACT(epoch ...)
so the queries will always return the duration in seconds. This is the same way as we calculate durations in the old value stream analytics backend.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #346761 (closed)