Skip to content

Conversation

lina-temporal
Copy link
Contributor

What changed?

  • Adds GetPureTasks, ExecutePureTask to the CHASM Tree (Node). These will be invoked from the timer queue executors in history service during processing of physical pure tasks.

Why?

  • Keeping the majority of the execution and tree traversal logic within CHASM keeps the timer queue's processing agnostic to CHASM's inner workings as possible.
  • Side Effect tasks do not need a GetPureTasks analog, as they keep a direct Ref to the component they're targetting, and their physical tasks are 1:1 with logical tasks.

How did you test it?

  • New tests

@lina-temporal lina-temporal requested review from alexshtin and yycptt May 2, 2025 02:30
@lina-temporal lina-temporal requested a review from a team as a code owner May 2, 2025 02:30
chasm/tree.go Outdated

validateContext := NewContext(context.Background(), n)
for _, task := range componentAttr.GetPureTasks() {
if task.ScheduledTime.AsTime().After(deadline) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use ms as the precision for doing comparison. queues.IsTimeExpired() has some more details.

Also caller can't simply use time.Now() as input, since there might be clock skew, which may cause the timer task to be executed before the scheduled time recorded in the state.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to truncate to the same precision as queues.

Also caller can't simply use time.Now() as input, since there might be clock skew, which may cause the timer task to be executed before the scheduled time recorded in the state.

The other PR with the caller is using t.Now() from the timer queue struct's ShardContext, as do other methods, and I'll update it to make use of IsTimeExpired for its physical task comparison.

//nolint:revive // type cast result is unchecked
return result[0].Interface().(error)
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an interesting question here. We are basically assuming for all the tasks processed, they will be invalidated at the end of the transaction.

If the validator implementation has a bug and doesn't invalid the task and the task status of that pure task happens to be Created, then we will won't generate a new physical task and the execution will get stuck.

If we blindly flip task status to be None, then we will have a infinite loop here.

It seems to be the best way is to Validate again after running the task and if the task is still validate return an internal error and DLQ the task.
Or we somehow mark the task as executed in-memory and upon close transaction, where we are already doing task Validating all the tasks, detect this case and return an error.

Not a super important issue but want to bring awareness here. Please help create a task to track this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Task to follow up created, OSS-4272

chasm/tree.go Outdated
return fmt.Errorf("ExecutePureTask called on a SideEffect task '%s'", registrableTask.fqType())
}

// TODO - instantiate CHASM engine and attach to context
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we only need to do this for side effect tasks. Pure tasks should not call any chasm engine methods.

@lina-temporal lina-temporal enabled auto-merge (squash) May 7, 2025 20:40
## What changed?
- Added physical pure task processing logic to the timer queue
executors.

## Why?
<!-- Tell your future self why have you made these changes -->

## How did you test it?
- New tests
@lina-temporal lina-temporal merged commit 344026c into main May 7, 2025
53 checks passed
@lina-temporal lina-temporal deleted the chasm_tree_pure_tasks branch May 7, 2025 21:37
josesa added a commit to josesa/temporal that referenced this pull request May 12, 2025
* main: (22 commits)
  Add host health metrics gauge (temporalio#7728)
  add rule expiration check (temporalio#7749)
  Add activity options to the pending activity info (temporalio#7727)
  Enable DLQ V2 for replication (temporalio#7746)
  chore: be smarter about when to use Stringer vs String (temporalio#7743)
  versioning entity workflows: enabling auto-restart pt1 (temporalio#7715)
  Refactor code generators (temporalio#7734)
  allow passive to generate replication tasks (temporalio#7713)
  Validate links in completion callbacks (temporalio#7726)
  CHASM: Engine Update/ReadComponent implementation (temporalio#7696)
  Enable transition history in dev env and tests (temporalio#7737)
  chore: Add Stringer tags (temporalio#7738)
  Add internal pod health check to DeepHealthCheck (temporalio#7709)
  Rename internal CHASM task processing interface (temporalio#7730)
  [Frontend] Log slow gRPC requests (temporalio#7718)
  Remove cap for dynamic config callback pool (temporalio#7723)
  Refactor updateworkflowoptions package (temporalio#7725)
  Remove a bunch of redundant utf-8 validation (temporalio#7720)
  [CHASM] Pure task processing - GetPureTasks, ExecutePureTasks (temporalio#7701)
  Send ActivityReset flag to the worker in heartbeat response (temporalio#7677)
  ...
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.

2 participants