-
Notifications
You must be signed in to change notification settings - Fork 1.2k
WorkflowExecutionInfo Field Conversions #715
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
- HistoryEvent EventTime is now *time.Time
| return TimePtr(UnixOrEmptyTime(nanos)) | ||
| } | ||
|
|
||
| func UnixOrZeroTime(nanos int64) time.Time { |
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.
UnixOrZeroTime to be renamed to UnixNano in later PR - UnixOrEmptyTime will now return empty time object.
| import "temporal/api/history/v1/message.proto"; | ||
| import "temporal/api/failure/v1/message.proto"; | ||
|
|
||
| message ReplicationInfo { |
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 was mistakenly removed in a prior commit. @alexshtin Appears we don't validate the build for proto?
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 don't. You supposed to regenerate go files every time manually. I agree, we should add this step and check if there are any changes in api dir after make proto.
| WorkflowTaskAttempt: sourceInfo.WorkflowTaskAttempt, | ||
| WorkflowTaskStartedTimestamp: sourceInfo.WorkflowTaskStartedTimestamp, | ||
| WorkflowTaskOriginalScheduledTimestamp: sourceInfo.WorkflowTaskOriginalScheduledTimestamp, | ||
| WorkflowTaskScheduledTimestamp: sourceInfo.WorkflowTaskScheduledTimestamp, |
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.
Long-standing bug that this was missing
| s.NotNil(response) | ||
| s.True(response.StartedTime.After(*expectedResponse.ScheduledTime)) | ||
| expectedResponse.StartedTime = response.StartedTime | ||
| expectedResponse.ScheduledTime = &time.Time{} |
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.
ScheduledTime should match event time. This was a bug hidden by missing field in copyWorfklowExecutionInfo
| ScheduledTimestamp: m.msb.timeSource.Now().UnixNano(), | ||
| StartedTimestamp: 0, | ||
| ScheduledTimestamp: timestamp.TimePtr(m.msb.timeSource.Now()), | ||
| StartedTimestamp: timestamp.UnixOrZeroTimePtr(0), |
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.
Outstanding Todo: Initialize 0 values with nil instead of 0 -- Note this applies to Time only. Durations (ie Timeouts) of 0 vs nil has actual distinction.
|
|
||
| // Back compat for GetHistorySize | ||
| if info.GetHistorySize() >= 0 && info.GetExecutionStats() == nil { | ||
| executionInfo.ExecutionStats = &persistenceblobs.ExecutionStats{HistorySize: 0} |
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.
Ignore bug here - fixed in a separate branch/commit with a test to ensure this works correctly migration. Will separate and apply to this PR shortly.
| import "temporal/api/history/v1/message.proto"; | ||
| import "temporal/api/failure/v1/message.proto"; | ||
|
|
||
| message ReplicationInfo { |
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 don't. You supposed to regenerate go files every time manually. I agree, we should add this step and check if there are any changes in api dir after make proto.
| WorkflowTaskStartedTimestamp *time.Time | ||
| WorkflowTaskScheduledTimestamp *time.Time | ||
| WorkflowTaskOriginalScheduledTimestamp *time.Time |
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 think these need to be renamed to *Time not *Timestamp.
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.
Next PR :)
| WorkflowTaskScheduleId: executionInfo.WorkflowTaskScheduleID, | ||
| WorkflowTaskStartedId: executionInfo.WorkflowTaskStartedID, | ||
| WorkflowTaskRequestId: executionInfo.WorkflowTaskRequestID, | ||
| WorkflowTaskTimeout: timestamp.DurationFromSeconds(executionInfo.WorkflowTaskTimeout), |
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 ideally, when we finish all time conversion we should not use timestamp.DurationFromSeconds and timestamp.TimestampFromTime at all. (Maybe only when we read from configs, but even there we can use duration and time).
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.
Definitely shouldn't need in serialization layers and agree with overall direction. However, some places we may still need it in code such as Persistence interfaces which take int64 timeouts in some areas to provide to cassandra as TTL (seconds only), whereas SQL layers may use timestamps.
| WorkflowTypeName: "wType", | ||
| WorkflowRunTimeout: 20, | ||
| DefaultWorkflowTaskTimeout: 13, | ||
| WorkflowRunTimeout: timestamp.DurationFromSeconds(20), |
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.
You lose beauty of go duration here. Wouldn't it be better: timestamp.DurationPtr(20 * time.Second)?
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.
Imho, I prefer having DurationFromUnit() to avoid mistakes in math and make refactoring a bit simpler. Can always drop down to `DurationPtr() with more complex times. Lets chat more.
| executionInfo := mutableState.executionInfo | ||
| executionInfo.HasRetryPolicy = true | ||
| executionInfo.WorkflowExpirationTime = s.now.Add(1000 * time.Second) | ||
| executionInfo.WorkflowExpirationTime = timestamp.TimeNowPtrUtcAddSeconds(1000) |
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 like this helper func :-). Yeah, definitely don't like.
| StartTimestamp: startTimeUnixNano, | ||
| ExecutionTimestamp: executionTimeUnixNano, | ||
| RunTimeout: int64(runTimeout), | ||
| RunTimeout: int64(timestamp.DurationValue(runTimeout).Round(time.Second).Seconds()), |
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 expect all these rounds to be temporary, right?
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.
Some of these will stay due to Cassandra TTL being in seconds.
What changed?
Incremental PR of changes on way to have MutableState be a proto everywhere. This PR:
persistence.InternalWorkflowExecutionInfo- This can return later when we are happy with object structure.persistenceblobs.ExecutionStatsinpersistenceblobs.WorkflowExecutionInfoand deprecateHistorySize--HistorySizeneeds to be dual written both as a field and in the new stats sub object until we validate complete migration and can remove the deprecated field. (v1.1+++)Bug Fixes:
createMutableState/copyWorkflowExecutionInfotest util now copiesWorkflowTaskScheduledTimestamphistoryEngine_test#TestRecordWorkflowTaskStarted***Sticky***tests correctly compareresponse.ScheduledTimeto the scheduled event writtentimestamp.UnixOrZeronow functions as UnixNano (to be renamed in seperate PR)timestamp.UnixOrEmptyhere to replace this aszerois ambiguousHow did you test it?
Local integration, unit tests. Buildkite validation
Potential risks
Time is now nillable and we could have nil pointer exceptions hidden about. This is the first incremental PR and more work will be done on this before in upcoming PRs. The pipelines should give us extra coverage here.