From c4a2686afb81235ab490d4a875ef416136c4c479 Mon Sep 17 00:00:00 2001 From: Quanzheng Long Date: Mon, 10 Jun 2019 17:12:25 -0700 Subject: [PATCH] Fix expiringTimeNano inconsistent between active and passive (#1982) --- service/history/mutableStateBuilder.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/service/history/mutableStateBuilder.go b/service/history/mutableStateBuilder.go index 8cc1b7c15ca..1ff0c4d1c40 100644 --- a/service/history/mutableStateBuilder.go +++ b/service/history/mutableStateBuilder.go @@ -3056,6 +3056,7 @@ func (e *mutableStateBuilder) AddContinueAsNewEvent( func rolloverAutoResetPointsWithExpiringTime( resetPoints *workflow.ResetPoints, prevRunID string, + nowNano int64, domainRetentionDays int32, ) *workflow.ResetPoints { @@ -3063,7 +3064,7 @@ func rolloverAutoResetPointsWithExpiringTime( return resetPoints } newPoints := make([]*workflow.ResetPointInfo, 0, len(resetPoints.Points)) - expiringTimeNano := time.Now().Add(time.Duration(domainRetentionDays) * time.Hour * 24).UnixNano() + expiringTimeNano := nowNano + int64(time.Duration(domainRetentionDays)*time.Hour*24) for _, rp := range resetPoints.Points { if rp.GetRunId() == prevRunID { rp.ExpiringTimeNano = common.Int64Ptr(expiringTimeNano) @@ -3149,7 +3150,7 @@ func (e *mutableStateBuilder) ReplicateWorkflowExecutionContinuedAsNewEvent( CronSchedule: startedAttributes.GetCronSchedule(), EventStoreVersion: newStateBuilder.GetEventStoreVersion(), BranchToken: newStateBuilder.GetCurrentBranch(), - PreviousAutoResetPoints: rolloverAutoResetPointsWithExpiringTime(startedAttributes.GetPrevAutoResetPoints(), prevRunID, domainRetentionDays), + PreviousAutoResetPoints: rolloverAutoResetPointsWithExpiringTime(startedAttributes.GetPrevAutoResetPoints(), prevRunID, continueAsNewEvent.GetTimestamp(), domainRetentionDays), } if continueAsNew.HasRetryPolicy {