Power actions are pending and never be executed

Power actions are pending and never be executed

book

Article ID: CTX693249

calendar_today

Updated On:

Description

Customer's power actions are pending and never be executed.

Resolution

Correct the DB server clock and update the records with incorrect date-time.

Example: 

update[SiteDB].[chb_State].[PowerManagementActions]
set ActionStartTime='2023-02-23', RequestTime='2023-02-23', ActionCompletionTime='2023-02-23'
  where ActionStartTime>'2023-02-27'


Problem Cause

With some unknown issue, system clock of the SQL Server is changed to Year-21xx from 2024.

So all ActionStartTime of poweractions' records will be logged with Year-21xx.
After DB clock correction, the time change to Year -2024.

Based on the SQL Procedure, for example now is 2024-03-05 10:01:00, so the LastMinute is 2024-03-05 10:00:00, but there are many records' ActionStartTime is 21xx, so the ActionsStartedInLastMinute is a large number, which causes maxActions will be 0 always. 
So the pending power actions will never be executed.

 declare @Now datetime = getutcdate();
 declare @LastMinute datetime = dateadd(minute, -1, @Now);
 @ActionsStartedInLastMinute =sum(case when ActionStartTime > @LastMinute then 1 else 0 end)
maxActions = Math.Min(maxActions, maxAbsoluteNewActionsPerMinute - actionsStartedInLastMinute)