We no longer call close on any of our gRPC Channels. This fixes possible segfaults caused by resources being deallocated while they are still in use.
What are the changes implemented in this PR?
Users in a wide variety of scenarios had reported intermittent crashes, often accompanied by warnings saying "1 metadata element(s) leaked". The logs would look similar to the following:
From this issue we infer that Channel.close is not behaving nicely in gRPC Python, and can cause resources to be deallocated while they are still in use. As gRPC itself uses native C libraries, this results in segfaults and crashes. We determine that the best course of action is to not close the Channel ourselves.
We've simply deleted the 3 places in our code that called close on a gRPC Channel. It has passed our CI tests and fixed user-reported issues, and it is what the gRPC maintainers themselves appear to recommend in the linked grpc issue.
What is the goal of this PR?
We no longer call
close
on any of our gRPC Channels. This fixes possible segfaults caused by resources being deallocated while they are still in use.What are the changes implemented in this PR?
Users in a wide variety of scenarios had reported intermittent crashes, often accompanied by warnings saying "1 metadata element(s) leaked". The logs would look similar to the following:
The same issue has also been reported in https://github.com/googleads/google-ads-python/issues/384, and a fix was suggested in:
From this issue we infer that
Channel.close
is not behaving nicely in gRPC Python, and can cause resources to be deallocated while they are still in use. As gRPC itself uses native C libraries, this results in segfaults and crashes. We determine that the best course of action is to not close the Channel ourselves.We've simply deleted the 3 places in our code that called
close
on a gRPCChannel
. It has passed our CI tests and fixed user-reported issues, and it is what the gRPC maintainers themselves appear to recommend in the linkedgrpc
issue.