8000 Fixes an issue where last-heartbeat time was set to the first event's timestamp by MichaelSnowden · Pull Request #3361 · temporalio/temporal · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fixes an issue where last-heartbeat time was set to the first event's timestamp #3361

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

MichaelSnowden
Copy link
Contributor

This PR fixes a bug where the first event for a pending activity would set its LastHeartbeatTime to the event time. I tested the fix by writing a test which calls the ReplicateActivityTaskStartedEvent method which had this issue, and verifies that the LastHeartbeatDetails are nil (as long as they were previously nil). The biggest risk to this change is if someone was depending on LastHeartbeatDetails on their pending activities being non-nil.

@MichaelSnowden MichaelSnowden requested a review from a team as a code owner September 10, 2022 01:49
@@ -2074,7 +2074,6 @@ func (e *MutableStateImpl) ReplicateActivityTaskStartedEvent(
ai.StartedEventId = event.GetEventId()
ai.RequestId = attributes.GetRequestId()
ai.StartedTime = event.GetEventTime()
ai.LastHeartbeatUpdateTime = ai.StartedTime
Copy link
Member
@yycptt yycptt Sep 10, 2022

Choose a reason for hiding this comment

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

There's another one in AddActivityTaskStartedEvent.

Also, we need to be very careful on this. and make sure it won't break sync activity task or heartbeat timeout calculation. Have you checked all usage of this field?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see any places relying on this being non-null in the value-read usages. It looks like they all use timestamp.TimeValue which has null checks. In DescribeWorkflowExecution, we are already only optionally setting that field. In timer_sequence:getActivityHeartbeatTimeout, we default to the start time if the LastHeartbeatUpdateTime is zero, which will have the same behavior. We also replace the field, but I don't see why that would cause any issues because the way it's read will still be the same usages as the ones I already checked.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, thanks for catching the one in AddActivityTaskStartedEvent, fixed.

@MichaelSnowden MichaelSnowden force-pushed the 3358-starttime-is-used-as-lastheartbeatupdatetime branch from 16ba94c to 6d7f8e9 Compare September 12, 2022 23:44
Copy link
Member
@yiminc yiminc left a comment

Choose a reason for hiding this comment

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

lgtm, but don't land this before 1.18

@yycptt yycptt requested a review from yux0 September 14, 2022 17:56
@MichaelSnowden MichaelSnowden enabled auto-merge (squash) September 20, 2022 20:04
@MichaelSnowden MichaelSnowden force-pushed the 3358-starttime-is-used-as-lastheartbeatupdatetime branch from f825283 to 3508fcc Compare September 23, 2022 22:27
@MichaelSnowden MichaelSnowden enabled auto-merge (squash) September 23, 2022 22:28
@MichaelSnowden MichaelSnowden merged commit c6fb6b8 into temporalio:master Sep 23, 2022
@MichaelSnowden MichaelSnowden deleted the 3358-starttime-is-used-as-lastheartbeatupdatetime branch December 29, 2022 23:00
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.

4 participants
0