Skip to content
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

Merged
merged 6 commits into from
Dec 16, 2017
Merged

Add Sticky Query to Cadence Server #464

merged 6 commits into from
Dec 16, 2017

Conversation

wxing1292
Copy link
Contributor

Add Sticky Query to Cadence Server
Add field in QueryWorkflowRequest, specifying whether to use sticky tasklist for query

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 66.47% when pulling ec85132 on revert into 963d13c on master.

Copy link

@yiminc-zz yiminc-zz left a 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.

StickyScheduleToStartTimeoutSeconds *int32 `json:"stickyScheduleToStartTimeoutSeconds,omitempty"`
ClientLibraryVersion *string `json:"clientLibraryVersion,omitempty"`
ClientFeatureVersion *string `json:"clientFeatureVersion,omitempty"`
ClientLang *string `json:"clientLang,omitempty"`

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.

Copy link
Contributor Author

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 {

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?

Copy link
Contributor Author

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 = ""

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

Copy link
Contributor Author

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.

featureVersion = ""
lang = ""
feature = NewFeatureImpl(libVersion, featureVersion, lang)
s.False(feature.SupportStickyQuery(), "Should support sticky query")
Copy link
Contributor

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"

Copy link
Contributor Author

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"
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

DomainUUID: common.StringPtr(taskToken.DomainID),
CompleteRequest: completeRequest,
})
var headers []yarpc.CallOption
Copy link
Contributor

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.

Copy link
Contributor Author

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


if len(persistenceToken) != 0 {
continuation, err = serializeHistoryToken(&getHistoryContinuationToken{
RunID: *matchingResp.WorkflowExecution.RunId,
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -275,9 +278,15 @@ pollLoop:
return emptyPollForDecisionTaskResponse, nil
}

isStickyEnabled := false
if describeResp.ExecutionConfiguration.StickyTaskList != nil && len(describeResp.ExecutionConfiguration.StickyTaskList.GetName()) != 0 {
Copy link
Contributor

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?

return nil, wh.error(err, scope)
}
clientFeature := client.NewFeatureImpl(
*response.ExecutionConfiguration.ClientLibraryVersion,
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor

@samarabbas samarabbas left a 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.

@@ -460,3 +476,16 @@ redirectLoop:
}
return err
}

func aggregateYarpcOptions(ctx context.Context, opts ...yarpc.CallOption) []yarpc.CallOption {
Copy link
Contributor

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?

Copy link
Contributor Author

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"
Copy link
Contributor

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.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 66.614% when pulling cdf0a36 on revert into bb26b98 on master.

@wxing1292 wxing1292 merged commit 4550c4e into master Dec 16, 2017
@wxing1292 wxing1292 deleted the revert branch December 16, 2017 05:42
resp.StartedEventId = matchingResponse.StartedEventId
resp.Query = matchingResponse.Query
resp.BacklogCountHint = matchingResponse.BacklogCountHint
resp.Attempt = matchingResponse.Attempt

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.

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.

5 participants