Files
Alex ShtinandGitHub 8e8f1b0f7c Remove license header from every file (#7689)
## What changed?
<!-- Describe what has changed in this PR -->
Remove license header from every file. Because it is really hard to
follow in this PR here is the summary:
1. License header is removed from all `.go` and `.proto` files
:fireworks::fireworks:🎆.
2. `LICENSE` file in the root directory has only Temporal and Uber
copyrights.
3. 5 other `LICENSE` files added to the packages which have copyrights
different from Temporal and Uber: Datadog, Xargin, "Mat Ryer, Tyler
Bunnell and contributors".
4. `license_file` flag is removed from all code generation tools.
5. `copyright_file` flag is removed from `go:generate mockgen`
directive.
6. All copyright related targets are removed from `Makefile`.
7. Updated Temporal copyright year to 2025 everywhere.

## Why?
<!-- Tell your future self why have you made these changes -->
I double checked with legal department that it is not needed to have
license header in every file. One file per repo is enough. I put all
copyrights to the root `LICENSE` file and removed header from all other
files. Also updated tools and `Makefile`.
2025-05-01 18:50:21 -07:00

134 lines
4.7 KiB
Go

package respondactivitytaskfailed
import (
"context"
"time"
enumspb "go.temporal.io/api/enums/v1"
"go.temporal.io/api/workflowservice/v1"
"go.temporal.io/server/api/historyservice/v1"
"go.temporal.io/server/common"
"go.temporal.io/server/common/definition"
"go.temporal.io/server/common/metrics"
"go.temporal.io/server/common/namespace"
"go.temporal.io/server/common/tasktoken"
"go.temporal.io/server/service/history/api"
"go.temporal.io/server/service/history/consts"
historyi "go.temporal.io/server/service/history/interfaces"
"go.temporal.io/server/service/history/workflow"
)
func Invoke(
ctx context.Context,
req *historyservice.RespondActivityTaskFailedRequest,
shard historyi.ShardContext,
workflowConsistencyChecker api.WorkflowConsistencyChecker,
) (resp *historyservice.RespondActivityTaskFailedResponse, retError error) {
namespaceEntry, err := api.GetActiveNamespace(shard, namespace.ID(req.GetNamespaceId()))
if err != nil {
return nil, err
}
namespace := namespaceEntry.Name()
request := req.FailedRequest
tokenSerializer := tasktoken.NewSerializer()
token, err0 := tokenSerializer.Deserialize(request.TaskToken)
if err0 != nil {
return nil, consts.ErrDeserializingToken
}
if err := api.SetActivityTaskRunID(ctx, token, workflowConsistencyChecker); err != nil {
return nil, err
}
var activityStartedTime time.Time
var taskQueue string
var workflowTypeName string
err = api.GetAndUpdateWorkflowWithNew(
ctx,
token.Clock,
definition.NewWorkflowKey(
token.NamespaceId,
token.WorkflowId,
token.RunId,
),
func(workflowLease api.WorkflowLease) (*api.UpdateWorkflowAction, error) {
mutableState := workflowLease.GetMutableState()
workflowTypeName = mutableState.GetWorkflowType().GetName()
if !mutableState.IsWorkflowExecutionRunning() {
return nil, consts.ErrWorkflowCompleted
}
scheduledEventID := token.GetScheduledEventId()
if scheduledEventID == common.EmptyEventID { // client call CompleteActivityById, so get scheduledEventID by activityID
scheduledEventID, err0 = api.GetActivityScheduledEventID(token.GetActivityId(), mutableState)
if err0 != nil {
return nil, err0
}
}
ai, activityRunning := mutableState.GetActivityInfo(scheduledEventID)
// First check to see if cache needs to be refreshed as we could potentially have stale workflow execution in
// some extreme cassandra failure cases.
if !activityRunning && scheduledEventID >= mutableState.GetNextEventID() {
metrics.StaleMutableStateCounter.With(shard.GetMetricsHandler()).Record(
1,
metrics.OperationTag(metrics.HistoryRespondActivityTaskFailedScope))
return nil, consts.ErrStaleState
}
if !activityRunning ||
ai.StartedEventId == common.EmptyEventID ||
(token.GetScheduledEventId() != common.EmptyEventID && token.Attempt != ai.Attempt) ||
(token.GetVersion() != common.EmptyVersion && token.Version != ai.Version) {
return nil, consts.ErrActivityTaskNotFound
}
if request.GetLastHeartbeatDetails() != nil {
// Save heartbeat details as progress
mutableState.UpdateActivityProgress(ai, &workflowservice.RecordActivityTaskHeartbeatRequest{
TaskToken: request.GetTaskToken(),
Details: request.GetLastHeartbeatDetails(),
Identity: request.GetIdentity(),
Namespace: request.GetNamespace(),
})
}
postActions := &api.UpdateWorkflowAction{}
failure := request.GetFailure()
mutableState.RecordLastActivityCompleteTime(ai)
retryState, err := mutableState.RetryActivity(ai, failure)
if err != nil {
return nil, err
}
// TODO uncomment once RETRY_STATE_PAUSED is supported
// if retryState != enumspb.RETRY_STATE_IN_PROGRESS && retryState != enumspb.RETRY_STATE_PAUSED {
if retryState != enumspb.RETRY_STATE_IN_PROGRESS {
// no more retry, and we want to record the failure event
if _, err := mutableState.AddActivityTaskFailedEvent(scheduledEventID, ai.StartedEventId, failure, retryState, request.GetIdentity(), request.GetWorkerVersion()); err != nil {
// Unable to add ActivityTaskFailed event to history
return nil, err
}
postActions.CreateWorkflowTask = true
}
activityStartedTime = ai.StartedTime.AsTime()
taskQueue = ai.TaskQueue
return postActions, nil
},
nil,
shard,
workflowConsistencyChecker,
)
if err == nil && !activityStartedTime.IsZero() {
metrics.ActivityE2ELatency.With(
workflow.GetPerTaskQueueFamilyScope(
shard.GetMetricsHandler(), namespace, taskQueue, shard.GetConfig(),
metrics.OperationTag(metrics.HistoryRespondActivityTaskFailedScope),
metrics.WorkflowTypeTag(workflowTypeName),
metrics.ActivityTypeTag(token.ActivityType),
),
).Record(time.Since(activityStartedTime))
}
return &historyservice.RespondActivityTaskFailedResponse{}, err
}