Skip to content

Enhancement: Support long-running workflow executions (Redis TTL handling) #14

@coderabbitai

Description

@coderabbitai

Context

Currently, the workflow execution counter in Redis uses a 1-hour TTL that is refreshed on every beginExecutionSetStatus call. This design assumes all workflow executions complete within 1 hour.

Problem

If we introduce longer-running workflows in the future, the Redis counter key could expire mid-execution, leading to:

  • Negative counter values when endExecutionSetStatus decrements a missing/expired key
  • Incorrect workflow active status in the database
  • Potential state inconsistencies

Proposed Enhancement

Update the Redis TTL handling logic:

  • beginExecutionSetStatus: Remove any TTL when count > 0 (use PERSIST)
  • endExecutionSetStatus: Only set the INACTIVITY_TIMEOUT TTL when count reaches 0

This ensures the counter persists while executions are active and only starts the inactivity timer once all executions complete.

Current Workaround

The current implementation is acceptable since we don't currently support workflows that run longer than 1 hour. This issue tracks the enhancement for future scalability.

References

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions