mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed? Cherry-pick versioning PRs - #9168 - Cache for system protection - #9262 - Cache for system protection - #9239 - Critical PR to enable sending `TargetVersionChanged` flag for Upgrade-on-CaN feature - #9147 - Tracks version drainage properly when version receives workflows via `VersioningOverride`. Needed for automated worker controllers to correctly scale versioned workers that received workflows via `VersioningOverride`. - #9300 - Needed for `approximate_backlog_count` metric to track Current and Ramping version tasks correctly - #9316 - Needed for `approximate_backlog_count` metric to track Current and Ramping version tasks correctly - #8957 - Contains minor metric improvement. Included because it adds a test harness that is used in the two metrics PRs above - #9250 - Bug fix of task rescheduling edge case during AutoUpgrade Transition ## Why? For OSS v1.30.2 ## How did you test it? - [x] built - [ ] run locally and tested manually - [x] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s) --- > [!NOTE] > **Medium Risk** > Touches history/matching worker-versioning paths, adding new caches and changing workflow task/start handling and backlog metric emission; incorrect caching or signaling could affect dispatch/upgrade behavior and observability. > > **Overview** > Adds new worker-versioning protections and upgrade signaling: workflow task started events now persist a `workflow_task_target_worker_deployment_version_changed` flag (and emit a new `workflow_target_version_changed_count` metric) under a new `EnableSendTargetVersionChanged` dynamic config. > > Introduces two new caches with metrics and dynamic config knobs: a `RoutingInfoCache` to avoid repeated `GetTaskQueueUserData` lookups during activity start/transition logic, and a `ReactivationSignalCache` plus `EnableVersionReactivationSignals` to dedupe and asynchronously send “reactivation” signals when workflows are pinned (via start/signal-with-start/reset/update-options) to potentially drained/inactive worker versions. > > Extends matching backlog metrics to support version-attributed reporting by adding `BacklogMetricsEmitInterval` and switching queue DB emission to *physical* backlog gauges (`physical_approximate_backlog_*`) when attribution is enabled, while keeping legacy gauges when disabled. > > Adds frontend scaffolding for a new visibility RPC `CountSchedules` (client plumbing, interception/metadata/quota wiring) but leaves the frontend handler unimplemented, and bumps `go.temporal.io/api` to `v1.62.2`. > > <sup>Written by [Cursor Bugbot]() for commit cb8ae14c86666654c51dd66ae91cb225722e1ba7. This will update automatically on new commits. Configure [here]().</sup> --------- Co-authored-by: Shahab Tajik <[email protected]> Co-authored-by: Shivam <[email protected]>
72 lines
3.3 KiB
Go
72 lines
3.3 KiB
Go
package interfaces
|
|
|
|
import (
|
|
"time"
|
|
|
|
enumspb "go.temporal.io/api/enums/v1"
|
|
taskqueuepb "go.temporal.io/api/taskqueue/v1"
|
|
enumsspb "go.temporal.io/server/api/enums/v1"
|
|
"go.temporal.io/server/service/history/tasks"
|
|
)
|
|
|
|
// TODO: This should be part of persistence layer
|
|
type WorkflowTaskInfo struct {
|
|
Version int64
|
|
ScheduledEventID int64
|
|
StartedEventID int64
|
|
RequestID string
|
|
WorkflowTaskTimeout time.Duration
|
|
// This is only needed to communicate task queue used after AddWorkflowTaskScheduledEvent.
|
|
TaskQueue *taskqueuepb.TaskQueue
|
|
Attempt int32
|
|
// Scheduled and Started timestamps are useful for transient workflow task: when transient workflow task finally completes,
|
|
// use these Timestamp to create scheduled/started events.
|
|
// Also used for recording latency metrics
|
|
ScheduledTime time.Time
|
|
StartedTime time.Time
|
|
// OriginalScheduledTime is to record the first scheduled workflow task during workflow task heartbeat.
|
|
// Client may to heartbeat workflow task by RespondWorkflowTaskComplete with ForceCreateNewWorkflowTask == true
|
|
// In this case, OriginalScheduledTime won't change. Then when time.Now().UTC()-OriginalScheduledTime exceeds
|
|
// some threshold, server can interrupt the heartbeat by enforcing to time out the workflow task.
|
|
OriginalScheduledTime time.Time
|
|
|
|
// Indicate type of the current workflow task (normal, transient, or speculative).
|
|
Type enumsspb.WorkflowTaskType
|
|
|
|
// These two fields are sent to workers in the WorkflowTaskStarted event. We need to save a
|
|
// copy in mutable state to know the last values we sent (which might have been in a
|
|
// transient event), otherwise a dynamic config change of the suggestion threshold could
|
|
// cause the WorkflowTaskStarted event that the worker used to not match the event we saved
|
|
// in history.
|
|
SuggestContinueAsNew bool
|
|
SuggestContinueAsNewReasons []enumspb.SuggestContinueAsNewReason
|
|
HistorySizeBytes int64
|
|
|
|
TargetWorkerDeploymentVersionChanged bool
|
|
// BuildIdRedirectCounter tracks the started build ID redirect counter for transient/speculative WFT. This
|
|
// info is to make sure the right redirect counter is used in the WFT started event created later
|
|
// for a transient/speculative WFT.
|
|
// Deprecated.
|
|
BuildIdRedirectCounter int64
|
|
// BuildId tracks the started build ID for transient/speculative WFT. This info is used for two purposes:
|
|
// - verify WFT completes by the same Build ID that started in the latest attempt
|
|
// - when persisting transient/speculative WFT, the right Build ID is used in the WFT started event
|
|
// Deprecated.
|
|
BuildId string
|
|
|
|
// Persisted timeout tasks for this workflow task. These are set when the timeout tasks are generated
|
|
// and used to delete them when the workflow task completes.
|
|
ScheduleToStartTimeoutTask *tasks.WorkflowTaskTimeoutTask
|
|
StartToCloseTimeoutTask *tasks.WorkflowTaskTimeoutTask
|
|
|
|
// Incrementing Stamp will invalidate the existing transfer/matching workflow task.
|
|
// Incrementing Stamp will ensure that the standby clusters reschedule the transfer tasks properly.
|
|
// Stamp is NOT scoped within a single wft, and it should never be decremented in the lifetime of the whole execution.
|
|
Stamp int32
|
|
}
|
|
|
|
type WorkflowTaskCompletionLimits struct {
|
|
MaxResetPoints int
|
|
MaxSearchAttributeValueSize int
|
|
}
|