-
Notifications
You must be signed in to change notification settings - Fork 216
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
Handle Client.Close on cloned clients #893
Conversation
workflowClient := client.(*WorkflowClient) | ||
|
||
// Confirm there is 1 unclosed client | ||
require.EqualValues(t, 1, *workflowClient.unclosedClients) |
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.
technically should use atomic.LoadInt32
, if you modify it with atomics, I think
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 in a test case. I can trust my lack of race issues in my own test case.
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 would do it just for consistency's sake. It's supposed to be an atomic int, it should be manipulated atomically even if Go lets you not do that. Trivial amount of extra typing.
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 also access the pointers directly in a non-atomic way to compare they point to the same spot. But I will make the change.
// set it to a new pointer of max to prevent decrementing on repeated Close | ||
// calls to this client. If the count has not reached zero, this close call is | ||
// ignored. | ||
if wc.unclosedClients != nil { |
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 shouldn't ever be nil, 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.
I cannot trust all places that create a client will set this. That includes tests and other code paths.
if err := wc.conn.Close(); err != nil { | ||
wc.logger.Warn("unable to close connection", tagError, err) | ||
|
||
if wc.conn != nil { |
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.
when is this nil?
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.
Test cases w/ mocks. This logic has not changed, I just moved the condition from the top of the function to down here.
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.
sounds good to me
This is reliably causing integration tests to go from 2 mins to 3. I am investigating... EDIT: This was due to an unclosed client causing a temporary goroutine leak causing a timeout |
What was changed
Use a counter to make sure only the last
Close()
of a shared-connection set of clients applies.Checklist