-
Notifications
You must be signed in to change notification settings - Fork 911
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
Move update registry from mutable state to workflow context #4032
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,6 @@ import ( | |
"sync" | ||
|
||
"github.com/gogo/protobuf/types" | ||
failurepb "go.temporal.io/api/failure/v1" | ||
protocolpb "go.temporal.io/api/protocol/v1" | ||
updatepb "go.temporal.io/api/update/v1" | ||
) | ||
|
@@ -41,8 +40,6 @@ type ( | |
|
||
HasPending(filterMessages []*protocolpb.Message) bool | ||
ProcessIncomingMessages(messages []*protocolpb.Message) error | ||
|
||
Clear() | ||
} | ||
|
||
Duplicate bool | ||
|
@@ -170,15 +167,6 @@ func (r *RegistryImpl) ProcessIncomingMessages(messages []*protocolpb.Message) e | |
return nil | ||
} | ||
|
||
func (r *RegistryImpl) Clear() { | ||
r.Lock() | ||
defer r.Unlock() | ||
for _, upd := range r.updates { | ||
upd.sendReject(r.clearFailure()) | ||
} | ||
r.updates = make(map[string]*Update) | ||
} | ||
|
||
func (r *RegistryImpl) getPendingUpdateNoLock(protocolInstanceID string) *Update { | ||
if upd, ok := r.updates[protocolInstanceID]; ok && upd.state == statePending { | ||
return upd | ||
|
@@ -193,17 +181,6 @@ func (r *RegistryImpl) getAcceptedUpdateNoLock(protocolInstanceID string) *Updat | |
return nil | ||
} | ||
|
||
func (r *RegistryImpl) clearFailure() *failurepb.Failure { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not needed anymore. |
||
return &failurepb.Failure{ | ||
Message: "update cleared, please retry", | ||
FailureInfo: &failurepb.Failure_ServerFailureInfo{ | ||
ServerFailureInfo: &failurepb.ServerFailureInfo{ | ||
NonRetryable: false, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func (r *RegistryImpl) remove(id string) { | ||
r.Lock() | ||
defer r.Unlock() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ import ( | |
"go.temporal.io/server/service/history/consts" | ||
"go.temporal.io/server/service/history/shard" | ||
"go.temporal.io/server/service/history/workflow" | ||
"go.temporal.io/server/service/history/workflow/update" | ||
) | ||
|
||
type ( | ||
|
@@ -212,7 +213,7 @@ func (handler *workflowTaskHandlerCallbacksImpl) handleWorkflowTaskStarted( | |
if workflowTask.StartedEventID != common.EmptyEventID { | ||
// If workflow task is started as part of the current request scope then return a positive response | ||
if workflowTask.RequestID == requestID { | ||
resp, err = handler.createRecordWorkflowTaskStartedResponse(mutableState, workflowTask, req.PollRequest.GetIdentity()) | ||
resp, err = handler.createRecordWorkflowTaskStartedResponse(mutableState, workflowContext.GetContext().UpdateRegistry(), workflowTask, req.PollRequest.GetIdentity()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
@@ -249,7 +250,7 @@ func (handler *workflowTaskHandlerCallbacksImpl) handleWorkflowTaskStarted( | |
metrics.TaskQueueTypeTag(enumspb.TASK_QUEUE_TYPE_WORKFLOW), | ||
) | ||
|
||
resp, err = handler.createRecordWorkflowTaskStartedResponse(mutableState, workflowTask, req.PollRequest.GetIdentity()) | ||
resp, err = handler.createRecordWorkflowTaskStartedResponse(mutableState, workflowContext.GetContext().UpdateRegistry(), workflowTask, req.PollRequest.GetIdentity()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
@@ -450,7 +451,7 @@ func (handler *workflowTaskHandlerCallbacksImpl) handleWorkflowTaskCompleted( | |
newMutableState workflow.MutableState | ||
) | ||
// hasPendingUpdates indicates if there are more pending updates (excluding those which are accepted/rejected by this workflow task). | ||
hasPendingUpdates := ms.UpdateRegistry().HasPending(request.GetMessages()) | ||
hasPendingUpdates := weContext.UpdateRegistry().HasPending(request.GetMessages()) | ||
hasBufferedEvents := ms.HasBufferedEvents() | ||
if err := namespaceEntry.VerifyBinaryChecksum(request.GetBinaryChecksum()); err != nil { | ||
wtFailedCause = newWorkflowTaskFailedCause( | ||
|
@@ -671,7 +672,7 @@ func (handler *workflowTaskHandlerCallbacksImpl) handleWorkflowTaskCompleted( | |
} | ||
|
||
// Send update results to gRPC API callers. | ||
err = ms.UpdateRegistry().ProcessIncomingMessages(req.GetCompleteRequest().GetMessages()) | ||
err = weContext.UpdateRegistry().ProcessIncomingMessages(req.GetCompleteRequest().GetMessages()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
@@ -690,7 +691,7 @@ func (handler *workflowTaskHandlerCallbacksImpl) handleWorkflowTaskCompleted( | |
resp := &historyservice.RespondWorkflowTaskCompletedResponse{} | ||
if request.GetReturnNewWorkflowTask() && createNewWorkflowTask { | ||
workflowTask, _ := ms.GetWorkflowTaskInfo(newWorkflowTaskScheduledEventID) | ||
resp.StartedResponse, err = handler.createRecordWorkflowTaskStartedResponse(ms, workflowTask, request.GetIdentity()) | ||
resp.StartedResponse, err = handler.createRecordWorkflowTaskStartedResponse(ms, weContext.UpdateRegistry(), workflowTask, request.GetIdentity()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
@@ -754,6 +755,7 @@ func (handler *workflowTaskHandlerCallbacksImpl) verifyFirstWorkflowTaskSchedule | |
|
||
func (handler *workflowTaskHandlerCallbacksImpl) createRecordWorkflowTaskStartedResponse( | ||
ms workflow.MutableState, | ||
updateRegistry update.Registry, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor and not blocking - this seems out of place here. Maybe better to pass the full workflow context and then extract the MS and registry within the function body? |
||
workflowTask *workflow.WorkflowTaskInfo, | ||
identity string, | ||
) (*historyservice.RecordWorkflowTaskStartedResponse, error) { | ||
|
@@ -801,7 +803,7 @@ func (handler *workflowTaskHandlerCallbacksImpl) createRecordWorkflowTaskStarted | |
} | ||
} | ||
|
||
response.Messages, err = ms.UpdateRegistry().CreateOutgoingMessages(workflowTask.StartedEventID) | ||
response.Messages, err = updateRegistry.CreateOutgoingMessages(workflowTask.StartedEventID) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
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 because long term goal is to to store registry out of workflow cache.