Skip to content

Reconnect disconnected channels automatically - #11154

Merged
kpayson64 merged 1 commit into
grpc:v1.3.xfrom
kpayson64:hack_for_disconnects
May 22, 2017
Merged

kpayson64 merged 1 commit into
grpc:v1.3.xfrom
kpayson64:hack_for_disconnects

Conversation

@kpayson64

Copy link
Copy Markdown
Contributor

Submission pending on #10813

The memory leak described in that poll request is likely the cause of #9461,
and without a fix this will introduce that leak to all channels.

@nathanielmanistaatgoogle nathanielmanistaatgoogle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just to double-check, because I think it might be slightly amazing: you've confirmed that the test fails in the absence of the non-test portion of this change?

Comment thread src/python/grpcio/grpc/_channel.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be a TODO (possibly a TODO(https://github.com/grpc/grpc/issues/11043)?).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think we can close out #11043 after this change.
#9884 is the "Make a proper fix in c-core"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this change is sufficient to close #11043 because #11043 is a wrapped-languages issue and this is a Python-only change.

#9884 might be the right issue for scoping the temporary-ness of this workaround; I think I'm a little thrown by the way it's being called "retries" and being described as a feature when I keep encountering it as "not trying hard enough the first time" and thinking of it as a bug.

Comment thread src/python/grpcio/grpc/_channel.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How certain are you that this is necessary? What does this do that the _moot call on the next line doesn't also do? If we can eliminate this call, we can also eliminate the maintenance of the dummy callback as an instance field, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed, thanks.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just for test sanity's sake let's make the value of this constant different from the value of _REQUEST.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Always leave the unnecessary ess off the end of assertEqual.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"Rebalance" the statements in this test so that nothing in the test method "undoes" what was done in setUp and also so that nothing in the test method "does" what will later be undone in tearDown. (I think this will mean that what will be left in your test will be only instantiating the thread pool, at which point you may choose to simply not bother with having a separate setUp/tearDown.)

A unit test with a setUp/tearDown and also only a single test method is particularly susceptible to premature generalization.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed setUp/tearDown

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We haven't been good about this in the past but it's on my list of things to clean up (and in the meantime, to avoid digging deeper): use the PEP8-style name test_reconnect.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing leading underscore on this name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@kpayson64

Copy link
Copy Markdown
Contributor Author

When the non-test changes are removed, the test fails:

  File "src/python/grpcio_tests/tests/unit/_reconnect_test.py", line 70, in testReconnect
    self.assertEquals(_RESPONSE, multi_callable(_REQUEST))
  File "/usr/local/google/home/kpayson/grpc2/py27/local/lib/python2.7/site-packages/grpc/_channel.py", line 507, in __call__
    return _end_unary_response_blocking(state, call, False, deadline)
  File "/usr/local/google/home/kpayson/grpc2/py27/local/lib/python2.7/site-packages/grpc/_channel.py", line 455, in _end_unary_response_blocking
    raise _Rendezvous(state, None, None, deadline)
_Rendezvous: <_Rendezvous of RPC that terminated with (StatusCode.UNAVAILABLE, Endpoint read failed)>

@kpayson64
kpayson64 force-pushed the hack_for_disconnects branch from 1b471b7 to 30d066b Compare May 16, 2017 18:50
@kpayson64

Copy link
Copy Markdown
Contributor Author

@nathanielmanistaatgoogle Addressed comments, back to you

Comment thread src/python/grpcio/grpc/_channel.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the significance of returning None, None rather than just None?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The second none is the try_to_connect arg, not part of the lambda.

Comment thread src/python/grpcio/grpc/_channel.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Typography nitpick: missing colon after closing parenthesis and start the prose of the comment on the same line rather than line-wrapping after the TODO(...):.

Huh. I guess the colon isn't required. Aww phooey; I've always liked it.

Comment thread src/python/grpcio/grpc/_channel.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this change is sufficient to close #11043 because #11043 is a wrapped-languages issue and this is a Python-only change.

#9884 might be the right issue for scoping the temporary-ness of this workaround; I think I'm a little thrown by the way it's being called "retries" and being described as a feature when I keep encountering it as "not trying hard enough the first time" and thinking of it as a bug.

@nathanielmanistaatgoogle nathanielmanistaatgoogle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm a little skittish about spawning a thread per channel, but... okay.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

assertEqual without the trailing ess here too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@kpayson64
kpayson64 changed the base branch from master to v1.3.x May 19, 2017 21:31
@kpayson64
kpayson64 force-pushed the hack_for_disconnects branch 2 times, most recently from 42f53b9 to 5bcbc79 Compare May 19, 2017 23:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants