-
Notifications
You must be signed in to change notification settings - Fork 754
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
Utilize shard clock for workflow / activity task #2744
Utilize shard clock for workflow / activity task #2744
Conversation
service/history/shard/context.go
Outdated
@@ -66,6 +67,8 @@ type ( | |||
GetEngine() (Engine, error) | |||
GetEngineWithContext(ctx context.Context) (Engine, error) | |||
|
|||
GetVClock() *clockpb.ShardClock |
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.
Replace VClock with ShardClock or VectorClock.
@@ -193,6 +195,14 @@ func (s *ContextImpl) GetMaxTaskIDForCurrentRangeID() int64 { | |||
return s.maxTaskSequenceNumber - 1 | |||
} | |||
|
|||
func (s *ContextImpl) GetVClock() *clockpb.ShardClock { | |||
s.rLock() | |||
clock := s.taskSequenceNumber |
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.
Is it guaranteed that any update to any workflow (in the shard) will cause this to increment? For example, if there is already a workflow task scheduled (but not started), and there comes a new signal, will the new signal cause the taskSequenceNumber to increase?
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.
Maybe that doesn't matter since this is mainly to detect stale shard (which happen only if someone steal it) in that case, the clock must have moved forward.
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.
Is it guaranteed that any update to any workflow (in the shard) will cause this to increment? For example, if there is already a workflow task scheduled (but not started), and there comes a new signal, will the new signal cause the taskSequenceNumber to increase?
yes, newly generated history event will use this sequence number
this GetVClock
is a read method, if business logic need to stamp an event, then there should be a generate method
* Add shard clock util * Add shard clock to shard context * Use shard clock for activity / workflow task
26e4aac
to
a534b58
Compare
@@ -150,6 +152,7 @@ func (t *transferQueueTaskExecutorBase) pushWorkflowTask( | |||
TaskQueue: taskqueue, | |||
ScheduleId: task.ScheduleID, | |||
ScheduleToStartTimeout: workflowTaskScheduleToStartTimeout, | |||
Clock: vclock.NewShardClock(t.shard.GetShardID(), task.TaskID), |
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.
@yiminc e.g. logic is using the task ID (generated from the sequence ID) as shard clock stamp
What changed?
Why?
see #2743
How did you test it?
Unit tests
Potential risks
N/A
Is hotfix candidate?
N/A