-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[CHASM] Pure task processing - GetPureTasks, ExecutePureTasks #7701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
chasm/tree.go
Outdated
|
||
validateContext := NewContext(context.Background(), n) | ||
for _, task := range componentAttr.GetPureTasks() { | ||
if task.ScheduledTime.AsTime().After(deadline) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) | ||
} | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
* 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) ...
What changed?
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?
GetPureTasks
analog, as they keep a directRef
to the component they're targetting, and their physical tasks are 1:1 with logical tasks.How did you test it?