mirror of
https://github.com/hanzoai/tasks.git
synced 2026-11-02 12:22:18 +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]>
98 lines
3.5 KiB
Go
98 lines
3.5 KiB
Go
package history
|
|
|
|
import (
|
|
"go.opentelemetry.io/otel/trace"
|
|
"go.temporal.io/server/chasm"
|
|
"go.temporal.io/server/client"
|
|
"go.temporal.io/server/common/persistence"
|
|
"go.temporal.io/server/common/persistence/serialization"
|
|
"go.temporal.io/server/common/persistence/visibility/manager"
|
|
"go.temporal.io/server/common/resource"
|
|
"go.temporal.io/server/common/sdk"
|
|
"go.temporal.io/server/common/testing/testhooks"
|
|
"go.temporal.io/server/common/worker_versioning"
|
|
"go.temporal.io/server/service/history/api"
|
|
"go.temporal.io/server/service/history/circuitbreakerpool"
|
|
"go.temporal.io/server/service/history/configs"
|
|
"go.temporal.io/server/service/history/events"
|
|
historyi "go.temporal.io/server/service/history/interfaces"
|
|
"go.temporal.io/server/service/history/replication"
|
|
"go.temporal.io/server/service/history/tasks"
|
|
"go.temporal.io/server/service/history/workflow"
|
|
wcache "go.temporal.io/server/service/history/workflow/cache"
|
|
"go.temporal.io/server/service/worker/workerdeployment"
|
|
"go.uber.org/fx"
|
|
)
|
|
|
|
type (
|
|
HistoryEngineFactoryParams struct {
|
|
fx.In
|
|
|
|
ClientBean client.Bean
|
|
MatchingClient resource.MatchingClient
|
|
SdkClientFactory sdk.ClientFactory
|
|
EventNotifier events.Notifier
|
|
Config *configs.Config
|
|
RawMatchingClient resource.MatchingRawClient
|
|
WorkflowCache wcache.Cache
|
|
ReplicationProgressCache replication.ProgressCache
|
|
EventSerializer serialization.Serializer
|
|
QueueFactories []QueueFactory `group:"queueFactory"`
|
|
ReplicationTaskFetcherFactory replication.TaskFetcherFactory
|
|
ReplicationTaskExecutorProvider replication.TaskExecutorProvider
|
|
TracerProvider trace.TracerProvider
|
|
PersistenceVisibilityMgr manager.VisibilityManager
|
|
EventBlobCache persistence.XDCCache
|
|
TaskCategoryRegistry tasks.TaskCategoryRegistry
|
|
ReplicationDLQWriter replication.DLQWriter
|
|
CommandHandlerRegistry *workflow.CommandHandlerRegistry
|
|
OutboundQueueCBPool *circuitbreakerpool.OutboundQueueCircuitBreakerPool
|
|
PersistenceRateLimiter replication.PersistenceRateLimiter
|
|
TestHooks testhooks.TestHooks
|
|
ChasmEngine chasm.Engine
|
|
VersionMembershipCache worker_versioning.VersionMembershipCache
|
|
ReactivationSignalCache worker_versioning.ReactivationSignalCache
|
|
WorkerDeploymentClient workerdeployment.Client
|
|
RoutingInfoCache worker_versioning.RoutingInfoCache
|
|
}
|
|
|
|
historyEngineFactory struct {
|
|
HistoryEngineFactoryParams
|
|
}
|
|
)
|
|
|
|
func (f *historyEngineFactory) CreateEngine(
|
|
shard historyi.ShardContext,
|
|
) historyi.Engine {
|
|
return NewEngineWithShardContext(
|
|
shard,
|
|
f.ClientBean,
|
|
f.MatchingClient,
|
|
f.SdkClientFactory,
|
|
f.EventNotifier,
|
|
f.Config,
|
|
f.VersionMembershipCache,
|
|
f.ReactivationSignalCache,
|
|
f.WorkerDeploymentClient,
|
|
f.RoutingInfoCache,
|
|
f.RawMatchingClient,
|
|
f.WorkflowCache,
|
|
f.ReplicationProgressCache,
|
|
f.EventSerializer,
|
|
f.QueueFactories,
|
|
f.ReplicationTaskFetcherFactory,
|
|
f.ReplicationTaskExecutorProvider,
|
|
api.NewWorkflowConsistencyChecker(shard, f.WorkflowCache),
|
|
f.TracerProvider,
|
|
f.PersistenceVisibilityMgr,
|
|
f.EventBlobCache,
|
|
f.TaskCategoryRegistry,
|
|
f.ReplicationDLQWriter,
|
|
f.CommandHandlerRegistry,
|
|
f.OutboundQueueCBPool,
|
|
f.PersistenceRateLimiter,
|
|
f.TestHooks,
|
|
f.ChasmEngine,
|
|
)
|
|
}
|