@@ -23,6 +23,7 @@ package task
2323
2424import (
2525 "context"
26+ "encoding/json"
2627 "errors"
2728 "fmt"
2829 "time"
@@ -35,6 +36,7 @@ import (
3536 "github.com/uber/cadence/common/cache"
3637 "github.com/uber/cadence/common/clock"
3738 "github.com/uber/cadence/common/constants"
39+ "github.com/uber/cadence/common/definition"
3840 "github.com/uber/cadence/common/log"
3941 "github.com/uber/cadence/common/log/tag"
4042 "github.com/uber/cadence/common/metrics"
@@ -442,6 +444,18 @@ func (t *transferActiveTaskExecutor) processCloseExecutionTaskHelper(
442444 domainName := mutableState .GetDomainEntry ().GetInfo ().Name
443445 children := mutableState .GetPendingChildExecutionInfos ()
444446
447+ // Add CronSchedule to search attributes if it's a cron workflow
448+ if isCron {
449+ searchAttr = copySearchAttributes (searchAttr )
450+ if searchAttr == nil {
451+ searchAttr = make (map [string ][]byte )
452+ }
453+ cronScheduleBytes , err := json .Marshal (executionInfo .CronSchedule )
454+ if err == nil {
455+ searchAttr [definition .CronSchedule ] = cronScheduleBytes
456+ }
457+ }
458+
445459 // we've gathered all necessary information from mutable state.
446460 // release the context lock since we no longer need mutable state builder and
447461 // the rest of logic is making RPC call, which takes time.
@@ -1007,6 +1021,17 @@ func (t *transferActiveTaskExecutor) processRecordWorkflowStartedOrUpsertHelper(
10071021 numClusters := (int16 )(len (domainEntry .GetReplicationConfig ().Clusters ))
10081022 updateTimestamp := t .shard .GetTimeSource ().Now ()
10091023
1024+ // Add CronSchedule to search attributes if it's a cron workflow
1025+ if isCron {
1026+ if searchAttr == nil {
1027+ searchAttr = make (map [string ][]byte )
1028+ }
1029+ cronScheduleBytes , err := json .Marshal (executionInfo .CronSchedule )
1030+ if err == nil {
1031+ searchAttr [definition .CronSchedule ] = cronScheduleBytes
1032+ }
1033+ }
1034+
10101035 // release the context lock since we no longer need mutable state builder and
10111036 // the rest of logic is making RPC call, which takes time.
10121037 release (nil )
0 commit comments