Skip to content

Conversation

@neil-xie
Copy link
Member

@neil-xie neil-xie commented Dec 11, 2025

Detailed Description
Add cronSchedule, executionStatus and scheduleExecutionTime to visibility records, which will be available for list workflow executions.
ExecutionStatus will have pending, started and the close statuses, we populate the actual close status for cron workflows instead of purely displaying continued as new.
ScheduledExecutionTime will calculate the actual execution time for cron workflows, before that it will be in pending status. When it generates the first decision task, the status will be switched to started.
These changes will require a schema upgrade.

ExecutionStatus is available in CLI by default, CronSchedule and ScheduledExecutionTime are optional, will be available using the flag --print_cron

% ./cadence --do default wf list --print_cron
       WORKFLOW TYPE      |                WORKFLOW ID                |                RUN ID                | TASK LIST | IS CRON | START TIME | EXECUTION TIME | CLOSE STATUS | HISTORY LENGTH | UPDATE TIME | EXECUTION STATUS | CRON SCHEDULE | SCHEDULED EXECUTION TIME
  test                    | test_workflow                             | f61149e0-bd7c-45b8-96ba-445ba3c5b8ff | tasklist  | true    | 13:31:49   | 14:00:00       | COMPLETED    |              0 | 16:00:00    | PENDING          | 0 * * * *     | 14:00:00
  main.sampleCronWorkflow | cron_016ba5f8-4e71-455d-b233-c25b34cb6a2e | a4a1d289-ec99-4451-a92a-e92e5d6064c3 | cronGroup | true    | 13:31:00   | 13:32:00       | COMPLETED    |              0 | 16:00:00    | STARTED          | * * * * *     | 13:32:00
  
       WORKFLOW TYPE      |                WORKFLOW ID                |                RUN ID                | TASK LIST | IS CRON | START TIME | EXECUTION TIME | END TIME |   CLOSE STATUS   | HISTORY LENGTH | UPDATE TIME | EXECUTION STATUS | CRON SCHEDULE | SCHEDULED EXECUTION TIME
  main.sampleCronWorkflow | cron_016ba5f8-4e71-455d-b233-c25b34cb6a2e | a4a1d289-ec99-4451-a92a-e92e5d6064c3 | cronGroup | true    | 13:31:00   | 13:32:00       | 16:00:00 | COMPLETED        |              0 | 16:00:00    | STARTED          | * * * * *     | 13:32:00
  main.sampleCronWorkflow | cron_016ba5f8-4e71-455d-b233-c25b34cb6a2e | 97766224-3d95-49eb-b0da-e1eca01d8bfa | cronGroup | true    | 13:29:00   | 13:30:00       | 13:31:00 | CONTINUED_AS_NEW |              3 | 16:00:00    | TIMED_OUT        | * * * * *     | 13:30:00
  main.sampleCronWorkflow | cron_016ba5f8-4e71-455d-b233-c25b34cb6a2e | 436c02b2-bc83-45fd-bb17-0558461ec60f | cronGroup | true    | 13:27:00   | 13:28:00       | 13:29:00 | CONTINUED_AS_NEW |              3 | 16:00:00    | TIMED_OUT        | * * * * *     | 13:28:00

Impact Analysis

  • Backward Compatibility: Yes
  • Forward Compatibility: Schema upgrade is required

Testing Plan

  • Unit Tests: Yes
  • Persistence Tests: Yes
  • Integration Tests: Yes
  • Compatibility Tests: Server won't start if schema is not upgraded

Rollout Plan

  • What is the rollout plan? staging -> production
  • Does the order of deployment matter? No
  • Is it safe to rollback? Does the order of rollback matter? Yes, just no value for the new fields, which is completely fine.
  • Is there a kill switch to mitigate the impact immediately? NA

@neil-xie neil-xie force-pushed the CDNC-16908-cron branch 2 times, most recently from 795891c to e3eb767 Compare December 16, 2025 22:02
Signed-off-by: Neil Xie <[email protected]>
Signed-off-by: Neil Xie <[email protected]>
…uledExecutionTime

This commit adds complete support for three new visibility fields to enable
better workflow lifecycle tracking and cron workflow scheduling.

Changes:
1. Type Mappers:
   - Added WorkflowExecutionStatus enum mappers (Thrift and Proto)
   - Added Ptr(), String(), UnmarshalText(), MarshalText() methods to WorkflowExecutionStatus
   - Updated WorkflowExecutionInfo mappers to include all three new fields

2. Elasticsearch Support:
   - Added three fields to VisibilityRecord struct for ES deserialization
   - Updated convertSearchResultToVisibilityRecord to populate the new fields
   - This fixes the issue where fields were written but not read from ES

3. Service Layer:
   - Updated timer active task executor to pass ScheduledExecutionTime
   - Updated transfer task executor base to include new fields in visibility records

The fields are now properly:
- Written to Elasticsearch during workflow start, upsert, and close
- Read from Elasticsearch when listing workflows
- Displayed in CLI output with --print_cron flag
- Mapped correctly between Thrift, Proto, and internal types

Signed-off-by: Neil Xie <[email protected]>
Signed-off-by: Neil Xie <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant