-
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
Implement describeMutableState #805
Implement describeMutableState #805
Conversation
client/history/client.go
Outdated
thriftCache map[string]historyserviceclient.Interface | ||
rpcFactory common.RPCFactory | ||
// TODO: consider refactor InquireCache into a separate struct | ||
InquireCacheLock sync.RWMutex |
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.
Are these intentionally Upper case?
client/history/client.go
Outdated
c.thriftCacheLock.RLock() | ||
client, ok := c.thriftCache[hostPort] | ||
c.thriftCacheLock.RUnlock() | ||
c.InquireCacheLock.RLock() |
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.
If you just do:
c.InquireCacheLock.RLock()
defer c.InquireCacheLock.Unlock()
here, you won't have to acquire the lock again and the lock is cleaner?
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.
As above, I mistakenly changed the naming and this is not part of my scope. But we can open another issue to optimize the locking mechanism.
One reason I can see that why they did this, is they want to release the lock earlier? But I can see that they did that on purpose to improve the performance, as the trade off, it will sacrify some readability
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.
ok got it.
client/history/client.go
Outdated
thriftCache map[string]historyserviceclient.Interface | ||
rpcFactory common.RPCFactory | ||
// TODO: consider refactor InquireCache into a separate struct | ||
InquireCacheLock sync.RWMutex |
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 this change?
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 a mistake when I refactor the naming. I will change it back. Thanks for reminding.
10: optional string shardId | ||
20: optional string historyAddr | ||
30: optional string otherInfo |
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 is this?
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.
@wxing1292 said he need more information in mutableStateBuilder like update/deleteActivityInfos, making sure that they are empty.
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.
but not called otherInfo, as a string, the idea is to dump all things from mutable state (cache version and persistence version).
the original type is preferable
moreover, shardId is a int64, i believe.
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.
Talked offline, I will get rid of otherInfo
contextFromCache, cacheHit := c.Get(key).(*workflowExecutionContext) | ||
releaseFunc := func(error) {} | ||
// If cache hit, we need to lock the cache to prevent race condition | ||
if cacheHit { |
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 feels complicated, it would be simpler if we just return from whatever in the cache, and provide another API to force unload the cache, which is also needed as an admin command.
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 s about requirement of the task. I will talk to you in uChat
service/history/historyEngine.go
Outdated
retResp.MutableStateInCache, retError = e.toMutableStateJSON(msb) | ||
otherInfo := "" | ||
if len(msb.updateActivityInfos) > 0 { | ||
otherInfo += "updateActivityInfos is not empty;" |
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 do we need this otherInfo? The toMutableStateJSON should already include everything, right?
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.
Like above. there are still someother information like updateActivityInfos. @wxing1292 you guys can discuss if they are really needed. I don't have too much context of how we are going to use it.
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.
well, i still prefer dumping everything as original type, not string
@@ -169,6 +169,22 @@ func newMutableStateBuilderWithReplicationState(config *Config, logger bark.Logg | |||
return s | |||
} | |||
|
|||
func (e *mutableStateBuilder) Unload() *persistence.WorkflowMutableState { |
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 function name is unclear. Maybe name it as CopyTo...
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 felt so too. did that because we already have
func (e *mutableStateBuilder) Load(state *persistence.WorkflowMutableState)"
doing the opposite.
CopyTo might not be a better name because mutableStateBuilder and mutabeState struct are not exactly the same.
To be more clear, we probably can call it loadFromMutableState and unloadToMutableState.
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.
Unload give false impression that you are resetting the mutable state.
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.
Make sense. How about rename it to "copyTo"?
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.
Approved because all my comments are addressed.
However, maybe wait for another approval(like from Yimin) before merging.
**/ | ||
InquiryWorkflowExecutionResponse InquiryWorkflowExecution(1: shared.DescribeWorkflowExecutionRequest inquiryRequest) | ||
InquireWorkflowExecutionResponse InquireWorkflowExecution(1: InquireWorkflowExecutionRequest inquireRequest) |
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.
let us use simple words here, try describe or get.
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.
+1 for Describe
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.
OK, I will rename them to DescribeXX
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. With 2 minor naming suggestion.
**/ | ||
InquiryWorkflowExecutionResponse InquiryWorkflowExecution(1: shared.DescribeWorkflowExecutionRequest inquiryRequest) | ||
InquireWorkflowExecutionResponse InquireWorkflowExecution(1: InquireWorkflowExecutionRequest inquireRequest) |
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.
+1 for Describe
@@ -169,6 +169,22 @@ func newMutableStateBuilderWithReplicationState(config *Config, logger bark.Logg | |||
return s | |||
} | |||
|
|||
func (e *mutableStateBuilder) Unload() *persistence.WorkflowMutableState { |
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.
Unload give false impression that you are resetting the mutable state.
7c3c6ae
to
d4c89a6
Compare
Initial PR, I will implement unit test for HistoryCache if there is no major issue in the code change.