-
Notifications
You must be signed in to change notification settings - Fork 215
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
Fix LA start to close timeout #1180
Fix LA start to close timeout #1180
Conversation
scheduleToCloseTimeout = startToCloseTimeout | ||
} | ||
deadline := calculateActivityDeadline(task.scheduledTime, startedTime, scheduleToCloseTimeout, startToCloseTimeout) | ||
if task.attempt > 1 && !task.expireTime.IsZero() && task.expireTime.Before(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.
This is still an open issue if we should removed this/can remove this. This expireTime
is calculated based on the ScheduleToCloseTimeout
and the workflow time, but is only used on the second attempt. This has been basically unchanged for 4+ years, but seems wrong.
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.
While wrong, let's leave for now
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.
Yeah I agree, just wanted to call this out since when we put Go on Core this will be something we have to deal with.
timeout := task.params.ScheduleToCloseTimeout | ||
if task.params.StartToCloseTimeout != 0 && task.params.StartToCloseTimeout < timeout { | ||
timeout = task.params.StartToCloseTimeout | ||
} | ||
timeoutDuration := timeout | ||
deadline := time.Now().Add(timeoutDuration) | ||
if task.attempt > 1 && !task.expireTime.IsZero() && task.expireTime.Before(deadline) { | ||
// this is attempt and expire time is before SCHEDULE_TO_CLOSE timeout | ||
deadline = task.expireTime | ||
} |
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.
I don't see anything obvious, but are there any ways that you can think of that this logic has changed with your new logic?
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.
The only change here is using the scheduled time + ScheduleToCloseTimeout
when calculating the deadline (used to be time.Now
). It probably won't effect many activities because for the first attempt scheduled time
will be close to time.Now
and subsequent attempts task.expireTime
uses workflow time so it will always be shorter than either 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.
So if today I have a schedule to close timeout of 5s, my second attempt would get the full 5s (even though that's improper)? But after this change, it will only get however much time remains the beginning of the first attempt? Sorry I didn't dig into how expireTime
is set. If this is the case, I may hit you up off-PR to communicate with one or two known heavy local activity users to confirm this is acceptable.
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.
So if today I have a schedule to close timeout of 5s, my second attempt
Today you would have no second attempt because schedule to close is not retried
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.
Confirmed off-PR that second-attempt after first-attempt-immediate-failure is bounded today by expireTime
regardless.
@@ -644,7 +635,11 @@ WaitResult: | |||
metricsHandler.Counter(metrics.LocalActivityExecutionCanceledCounter).Inc(1) | |||
return &localActivityResult{err: ErrCanceled, task: task} | |||
} else if ctx.Err() == context.DeadlineExceeded { | |||
return &localActivityResult{err: ErrDeadlineExceeded, task: task} | |||
if task.params.ScheduleToCloseTimeout != 0 && time.Now().After(info.scheduledTime.Add(task.params.ScheduleToCloseTimeout)) { |
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.
I wish there was a better way to know which timeout was hit instead of having to do math here.
@@ -156,11 +156,13 @@ type ( | |||
// LocalActivityOptions stores local activity specific parameters that will be stored inside of a context. | |||
LocalActivityOptions struct { | |||
// ScheduleToCloseTimeout - The end to end timeout for the local activity including retries. | |||
// This field is required. | |||
// At least on of ScheduleToCloseTimeout or StartToCloseTimeout is required. | |||
// defaults to StartToCloseTimeout if not set. |
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.
The default for ScheduleToCloseTimeout
for normal activities is infinity. We could be consistent here, but that might be a breaking change.
e305c8d
to
0e260ef
Compare
This PR fixes a few issues with local activities in Got
ScheduleToCloseTimeout
was overridingStartToCloseTimeout
if both were setLocalActivityOptions
were not accurateSCHEDULE_TO_CLOSE
timeout and that is not retry ableActivityInfo
in local activities was missing some fields