Skip to content

Commit

Permalink
Record error info for retried activities (#1873)
Browse files Browse the repository at this point in the history
Exposes the lastFailureReason and lastFailureDetails, which exist in the mutable state, through
the ActivityTaskStartedEvent in the history. The fields were added to ActivityTaskStartedEvent
as part of uber/cadence-idl#15

Resolves: #1873
  • Loading branch information
emrahs committed Mar 13, 2020
1 parent bb7d24d commit 3a82e3b
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 16 deletions.
102 changes: 94 additions & 8 deletions .gen/go/shared/shared.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion idls
Submodule idls updated 2 files
+1 −0 .gitignore
+2 −0 thrift/shared.thrift
25 changes: 20 additions & 5 deletions service/history/historyBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,16 @@ func (b *historyBuilder) AddActivityTaskScheduledEvent(decisionCompletedEventID
return b.addEventToHistory(event)
}

func (b *historyBuilder) AddActivityTaskStartedEvent(scheduleEventID int64, attempt int32, requestID string,
identity string) *workflow.HistoryEvent {
event := b.newActivityTaskStartedEvent(scheduleEventID, attempt, requestID, identity)
func (b *historyBuilder) AddActivityTaskStartedEvent(
scheduleEventID int64,
attempt int32,
requestID string,
identity string,
lastFailureReason string,
lastFailureDetails []byte,
) *workflow.HistoryEvent {
event := b.newActivityTaskStartedEvent(scheduleEventID, attempt, requestID, identity, lastFailureReason,
lastFailureDetails)

return b.addEventToHistory(event)
}
Expand Down Expand Up @@ -591,14 +598,22 @@ func (b *historyBuilder) newActivityTaskScheduledEvent(decisionTaskCompletedEven
return historyEvent
}

func (b *historyBuilder) newActivityTaskStartedEvent(scheduledEventID int64, attempt int32, requestID string,
identity string) *workflow.HistoryEvent {
func (b *historyBuilder) newActivityTaskStartedEvent(
scheduledEventID int64,
attempt int32,
requestID string,
identity string,
lastFailureReason string,
lastFailureDetails []byte,
) *workflow.HistoryEvent {
historyEvent := b.msBuilder.CreateNewHistoryEvent(workflow.EventTypeActivityTaskStarted)
attributes := &workflow.ActivityTaskStartedEventAttributes{}
attributes.ScheduledEventId = common.Int64Ptr(scheduledEventID)
attributes.Attempt = common.Int32Ptr(attempt)
attributes.Identity = common.StringPtr(identity)
attributes.RequestId = common.StringPtr(requestID)
attributes.LastFailureReason = common.StringPtr(lastFailureReason)
attributes.LastFailureDetails = lastFailureDetails
historyEvent.ActivityTaskStartedEventAttributes = attributes

return historyEvent
Expand Down
6 changes: 4 additions & 2 deletions service/history/mutableStateBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2195,7 +2195,8 @@ func (e *mutableStateBuilder) addTransientActivityStartedEvent(
}

// activity task was started (as transient event), we need to add it now.
event := e.hBuilder.AddActivityTaskStartedEvent(scheduleEventID, ai.Attempt, ai.RequestID, ai.StartedIdentity)
event := e.hBuilder.AddActivityTaskStartedEvent(scheduleEventID, ai.Attempt, ai.RequestID, ai.StartedIdentity,
ai.LastFailureReason, ai.LastFailureDetails)
if !ai.StartedTime.IsZero() {
// overwrite started event time to the one recorded in ActivityInfo
event.Timestamp = common.Int64Ptr(ai.StartedTime.UnixNano())
Expand All @@ -2216,7 +2217,8 @@ func (e *mutableStateBuilder) AddActivityTaskStartedEvent(
}

if !ai.HasRetryPolicy {
event := e.hBuilder.AddActivityTaskStartedEvent(scheduleEventID, ai.Attempt, requestID, identity)
event := e.hBuilder.AddActivityTaskStartedEvent(scheduleEventID, ai.Attempt, requestID, identity,
ai.LastFailureReason, ai.LastFailureDetails)
if err := e.ReplicateActivityTaskStartedEvent(event); err != nil {
return nil, err
}
Expand Down

0 comments on commit 3a82e3b

Please sign in to comment.