Skip to content

[Fix Python Deadlock] Guard grpc_ssl_credentials_create with nogil (v1.59.x backport)#34725

Merged
XuanWang-Amos merged 1 commit intogrpc:v1.59.xfrom
XuanWang-Amos:backport-1.59-fix_ssl_create_hanging
Oct 18, 2023
Merged

[Fix Python Deadlock] Guard grpc_ssl_credentials_create with nogil (v1.59.x backport)#34725
XuanWang-Amos merged 1 commit intogrpc:v1.59.xfrom
XuanWang-Amos:backport-1.59-fix_ssl_create_hanging

Conversation

@XuanWang-Amos
Copy link
Copy Markdown
Contributor

Backport of #34712 to v1.59.x.

Fix: #34672
With some recent changes in core, now grpc_ssl_credentials_create is guarded by gpr_once_init. In our current implementation, The thread got gpr_once_init lock might require GIL lock during the execution of grpc_ssl_credentials_create, which might cause a deadlock if another thread is holding GIL lock and waiting for gpr_once_init lock.

This change adds with nogil to calls to native function grpc_ssl_credentials_create to make sure GIL is released before calling grpc_ssl_credentials_create.

…rpc#34712)

Fix: grpc#34672
With some recent changes in core, now `grpc_ssl_credentials_create` is
guarded by `gpr_once_init`. In our current implementation, The thread
got `gpr_once_init` lock might require GIL lock during the execution of
`grpc_ssl_credentials_create`, which might cause a deadlock if another
thread is holding GIL lock and waiting for `gpr_once_init` lock.

This change adds `with nogil` to calls to native function
`grpc_ssl_credentials_create` to make sure GIL is released before
calling `grpc_ssl_credentials_create`.
<!--

If you know who should review your pull request, please assign it to
that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the
appropriate
lang label.

-->
@XuanWang-Amos XuanWang-Amos added the release notes: no Indicates if PR should not be in release notes label Oct 18, 2023
@XuanWang-Amos XuanWang-Amos marked this pull request as ready for review October 18, 2023 18:05
@XuanWang-Amos XuanWang-Amos requested a review from gnossen October 18, 2023 18:05
@XuanWang-Amos XuanWang-Amos merged commit 50b02da into grpc:v1.59.x Oct 18, 2023
@XuanWang-Amos XuanWang-Amos deleted the backport-1.59-fix_ssl_create_hanging branch October 18, 2023 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lang/Python release notes: no Indicates if PR should not be in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants