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

Support None to not load any data for the persistence loading policy … #320

Closed
wants to merge 2 commits into from

Conversation

zklgame
Copy link
Contributor

@zklgame zklgame commented Aug 7, 2023

Support attributes loading None in RPC with code refactor

@zklgame
Copy link
Contributor Author

zklgame commented Aug 7, 2023

@longquanzheng The s.client.QueryWorkflow seems to be needed whatever the loading policies are since it gets other info like worker url, run id, timestamp.

@codecov
Copy link

codecov bot commented Aug 7, 2023

Codecov Report

Merging #320 (85a48f6) into main (c01cd95) will increase coverage by 0.28%.
The diff coverage is 94.66%.

@@            Coverage Diff             @@
##             main     #320      +/-   ##
==========================================
+ Coverage   71.62%   71.90%   +0.28%     
==========================================
  Files          54       54              
  Lines        4423     4457      +34     
==========================================
+ Hits         3168     3205      +37     
+ Misses       1019     1017       -2     
+ Partials      236      235       -1     
Files Changed Coverage Δ
service/interpreter/persistence.go 92.57% <92.10%> (-1.30%) ⬇️
service/api/service.go 77.46% <97.29%> (+2.41%) ⬆️

... and 3 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@longquanzheng
Copy link
Contributor

longquanzheng commented Aug 7, 2023

@longquanzheng The s.client.QueryWorkflow seems to be needed whatever the loading policies are since it gets other info like worker url, run id, timestamp.

ahh right. Maybe you can fix/improve this in the same PR(or separate if you prefer): https://github.com/indeedeng/iwf/blob/main/service/api/service.go#L112
We could always put this URL into memo/caching is not being requested for starting workflow.
So that this RPC can try to use DescribeWF API to load workerURL and runId/timestamp when loading policy is none. (note changing the startWF code will only affect new workflow so you need to think about backward compatibility)

Because avoiding query is a very important optimization here. Query is very expensive. Otherwise none is useless for rpc.

@longquanzheng
Copy link
Contributor

For testing, if we are able to optimize/improve it by avoid calling query workflow, I wonder if we can assert it in the test to make sure the query API is not being called. (we may need to think about some "hack" just for testing)

@zklgame
Copy link
Contributor Author

zklgame commented Aug 7, 2023

@longquanzheng The s.client.QueryWorkflow seems to be needed whatever the loading policies are since it gets other info like worker url, run id, timestamp.

ahh right. Maybe you can fix/improve this in the same PR(or separate if you prefer): https://github.com/indeedeng/iwf/blob/main/service/api/service.go#L112 We could always put this URL into memo/caching is not being requested for starting workflow. So that this RPC can try to use DescribeWF API to load workerURL and runId/timestamp when loading policy is none. (note changing the startWF code will only affect new workflow so you need to think about backward compatibility)

Because avoiding query is a very important optimization here. Query is very expensive. Otherwise none is useless for rpc.

Sounds like better making it in another PR since the new PR will include quite work:

  1. get the workUrl, runId, timestamp from DescribeWorkflow for Temporal
  2. support backward compatibility
  3. test the calling of the query API

} else if loadingType == iwfidl.NONE {
return []iwfidl.KeyValue{}
} else {
panic("not supported loading type " + loadingType)
}
}

func LoadSearchAttributes(loadingKeys []string, allSearchAttributes []iwfidl.SearchAttribute) []iwfidl.SearchAttribute {
Copy link
Contributor

Choose a reason for hiding this comment

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

As our/golang convention, the internal usage of a method/function should be kept as "private". In golang, the any var/method/func start with lower case is package private loadSearchAttributes.
Also there is already another method LoadSearchAttributes, you may want to rename it to internalLoadSearchAttributes to be more clear.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or maybe loadSearchAttributesByRequestedKeys

}
dataAttributes = am.GetAllDataObjects()
} else {
dataAttributes = LoadDataAttributes(request.Keys, am.GetAllDataObjects())
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's a bit wastful to call am.GetAllDataObjects() before LoadDataAttributes. Because GetAllDataObjects will allocate a new slice/array to hold all the data attributes. Maybe LoadDataAttributes can just access to all the DAs directly

saPolicy := req.GetSearchAttributesLoadingPolicy()
if saPolicy.GetPersistenceLoadingType() != iwfidl.ALL_WITHOUT_LOCKING {
switch saPolicy.GetPersistenceLoadingType() {
case iwfidl.PARTIAL_WITH_EXCLUSIVE_LOCK:
Copy link
Contributor

Choose a reason for hiding this comment

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

we need to return error for this case. this will be supported in #305

@zklgame
Copy link
Contributor Author

zklgame commented Aug 25, 2023

Close this one and to make a new one since it has been several weeks.

@zklgame zklgame closed this Aug 25, 2023
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.

2 participants