Details
Assignee
UnassignedUnassignedReporter
David HustaceDavid HustaceLabels
Components
Priority
Minor
Details
Details
Assignee
Unassigned
UnassignedReporter
David Hustace
David HustaceLabels
Components
Priority
PagerDuty
PagerDuty
PagerDuty
Created February 2, 2018 at 1:52 PM
Updated September 21, 2021 at 7:25 PM
When we first implemented the triggers that evaluated lastautomationtime and lasteventtime, the PostgreSQL versions we supported didn't include the GREATEST function so we used the next best thing which was COALESCE which favored lastautomationtime. However, since 8.1, PostgreSQL has supported the GREATEST function and it should be used as it would be more accurate to evaluate that most recent date of the two values:
Example:
<trigger name="selectAlarmsToFullGarbageCollect" operator=">=" row-count="1" > <statement> SELECT alarmid, eventuei, reductionkey, now() AS _ts FROM alarms WHERE COALESCE(lastautomationtime, lasteventtime) < now() - interval '8 days' </statement> </trigger>
Should be:
<trigger name="selectAlarmsToFullGarbageCollect" operator=">=" row-count="1" > <statement> SELECT alarmid, eventuei, reductionkey, now() AS _ts FROM alarms WHERE GREATEST(lastautomationtime, lasteventtime) < now() - interval '8 days' </statement> </trigger> </code>