-
Notifications
You must be signed in to change notification settings - Fork 805
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
Add Sticky Query to Cadence Server #464
Conversation
…asklist for query
…se sticky query or not
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 should not mix 2 changes into one PR. It also feels like an overkill to adding all those headers/versions just for query with no history.
.gen/go/shared/types.go
Outdated
StickyScheduleToStartTimeoutSeconds *int32 `json:"stickyScheduleToStartTimeoutSeconds,omitempty"` | ||
ClientLibraryVersion *string `json:"clientLibraryVersion,omitempty"` | ||
ClientFeatureVersion *string `json:"clientFeatureVersion,omitempty"` | ||
ClientLang *string `json:"clientLang,omitempty"` |
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'm not sure we want to public expose these to users.
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.
removed
renamed getworkflow next event id to get mutable state, which returns these things.
} | ||
|
||
// SupportStickyQuery whether a client support sticky query | ||
func (feature *FeatureImpl) SupportStickyQuery() bool { |
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 will need to check lang as well?
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.
no, i do not need to check the lang,
but since i am adding this functionality, might as well also include this
func (e *mutableStateBuilder) clearStickyness() { | ||
e.executionInfo.StickyTaskList = "" | ||
e.executionInfo.StickyScheduleToStartTimeout = 0 | ||
e.executionInfo.ClientLibraryVersion = "" |
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.
does not feel right to tie the client version to stickiness
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.
why?
from the lease of sticky tasklist, all new worker will use sticky by default.
which means if server decide to put anything in the sticky tasklist, server need to be sure that the worker can handle it.
the ordinary tasklist is used when a worker first poll from server.
and at that time, server can only assume that worker has the very basic functionality.
common/client/clientFeature_test.go
Outdated
featureVersion = "" | ||
lang = "" | ||
feature = NewFeatureImpl(libVersion, featureVersion, lang) | ||
s.False(feature.SupportStickyQuery(), "Should support sticky query") |
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 may want to correct the message. "Not"
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.
typo fixed
common/rpc.go
Outdated
// FeatureVersionHeaderName refers to the name of the | ||
// tchannel / http header that contains the client | ||
// feature version | ||
FeatureVersionHeaderName = "cadence-client-feature-version" |
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.
How does the client discover which feature version to pass in as header.
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.
client change has already merged: cadence-workflow/cadence-go-client#316
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.
What I meant is we need to document this feature version on server.
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.
added:
// the feature version sent from client represents the
// feature set of the cadence client library support.
// This can be used for client capibility check, on
// Cadence server, for backward compatibility
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 feature version sent from client represents the
// version of the server feature set expected by the client.
// Cadence service is expected to reject clients that have incompatible major version.
// In some cases a client with a smaller major version than the service is allowed for the backwards compatibility. Clients with a larger major version are always rejected.
service/frontend/handler.go
Outdated
DomainUUID: common.StringPtr(taskToken.DomainID), | ||
CompleteRequest: completeRequest, | ||
}) | ||
var headers []yarpc.CallOption |
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 you want to put this logic within the history/matching clients. I think we should just pass headers for all API calls on history and matching.
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.
done for all matching and history client
service/frontend/handler.go
Outdated
|
||
if len(persistenceToken) != 0 { | ||
continuation, err = serializeHistoryToken(&getHistoryContinuationToken{ | ||
RunID: *matchingResp.WorkflowExecution.RunId, |
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.
Use generated getter for RunId
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.
done
service/matching/matchingEngine.go
Outdated
@@ -275,9 +278,15 @@ pollLoop: | |||
return emptyPollForDecisionTaskResponse, nil | |||
} | |||
|
|||
isStickyEnabled := false | |||
if describeResp.ExecutionConfiguration.StickyTaskList != nil && len(describeResp.ExecutionConfiguration.StickyTaskList.GetName()) != 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.
I see this check in multiple places. Can we just have an API on ExecutionConfiguration for StickyTasklist?
service/frontend/handler.go
Outdated
return nil, wh.error(err, scope) | ||
} | ||
clientFeature := client.NewFeatureImpl( | ||
*response.ExecutionConfiguration.ClientLibraryVersion, |
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.
Can we use generated getter?
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.
done
@@ -142,6 +142,9 @@ type ( | |||
CancelRequestID string | |||
StickyTaskList string | |||
StickyScheduleToStartTimeout int32 | |||
ClientLibraryVersion string |
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 made the changes to mutable state API, but where are the cassandra persistence changes to support CRUD for these new values.
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.
fixed
…ence of client version
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.
Looks good. You can merge it in after addressing my minor comments.
client/history/client.go
Outdated
@@ -460,3 +476,16 @@ redirectLoop: | |||
} | |||
return err | |||
} | |||
|
|||
func aggregateYarpcOptions(ctx context.Context, opts ...yarpc.CallOption) []yarpc.CallOption { |
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 method is defined twice, can you move it to common?
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.
done
common/rpc.go
Outdated
// FeatureVersionHeaderName refers to the name of the | ||
// tchannel / http header that contains the client | ||
// feature version | ||
FeatureVersionHeaderName = "cadence-client-feature-version" |
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.
What I meant is we need to document this feature version on server.
resp.StartedEventId = matchingResponse.StartedEventId | ||
resp.Query = matchingResponse.Query | ||
resp.BacklogCountHint = matchingResponse.BacklogCountHint | ||
resp.Attempt = matchingResponse.Attempt |
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 Attempt should not be removed.
Add Sticky Query to Cadence Server
Add field in QueryWorkflowRequest, specifying whether to use sticky tasklist for query