Skip to content
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

[Python][FlightRPC] Interpreter deadlock when using GeneratorStream and Acero + Python UDFs #40004

Closed
lupko opened this issue Feb 8, 2024 · 0 comments · Fixed by #40005
Closed
Assignees
Labels
Component: FlightRPC Component: Python Critical Fix Bugfixes for security vulnerabilities, crashes, or invalid data. Type: bug
Milestone

Comments

@lupko
Copy link
Contributor

lupko commented Feb 8, 2024

Describe the bug, including details regarding any error messages, version, and platform.

Hello,

I'm on Arrow 15.0, Python 3.11. I have a Flight RPC service that does roughly the following:

  • Declares and registers a custom UDF compute function (this combines calls to couple of existing compute functions)
  • During GetFlightInfo, code prepares and starts Acero:
    • Declaration uses source + project node
    • The project node is configured so that the custom UDF compute is unleashed on some of the columns
    • A RecordBatchReader is created using Declaration.to_reader()
  • During DoGet, service returns flight.GeneratorStream() with the reader created using Declaration.to_reader()
    • Code uses GeneratorStream instead of flight.RecordBatchStream because there is likelyhood that GetFlightInfo could produce multiple pieces to concatenate into DoGet stream.

This service is then called from Java land which quite reliably triggers full interpreter deadlock of the server process.
The thread dump of the stuck process: https://gist.github.com/lupko/c4491df7a36247b48ba0248c2d5f9ae6

I have been playing around and when I got the GeneratorStream out of the picture (e.g. used RecordBatchStream instead), there were no deadlocks.

Following the traces from thread dump, I believe the problem is here:

check_flight_status(

So in the end I think the situation is: The call does not release GIL before it goes to get Next(). But it will never get Next() because to do so Acero needs to run Python UDF which needs GIL as well.

I did try fix on a local build - wrapping the call in with nogil - and all is good. I will create PR shortly.

Component(s)

FlightRPC, Python

@lupko lupko added the Type: bug label Feb 8, 2024
lidavidm pushed a commit that referenced this issue Feb 8, 2024
Fixes #40004.

* Closes: #40004

Authored-by: lupko <lubomir.slivka@gooddata.com>
Signed-off-by: David Li <li.davidm96@gmail.com>
@lidavidm lidavidm added this to the 16.0.0 milestone Feb 8, 2024
@pitrou pitrou modified the milestones: 16.0.0, 15.0.1 Feb 14, 2024
dgreiss pushed a commit to dgreiss/arrow that referenced this issue Feb 19, 2024
…pache#40005)

Fixes apache#40004.

* Closes: apache#40004

Authored-by: lupko <lubomir.slivka@gooddata.com>
Signed-off-by: David Li <li.davidm96@gmail.com>
raulcd pushed a commit that referenced this issue Feb 20, 2024
Fixes #40004.

* Closes: #40004

Authored-by: lupko <lubomir.slivka@gooddata.com>
Signed-off-by: David Li <li.davidm96@gmail.com>
@amoeba amoeba added the Critical Fix Bugfixes for security vulnerabilities, crashes, or invalid data. label Feb 27, 2024
zanmato1984 pushed a commit to zanmato1984/arrow that referenced this issue Feb 28, 2024
…pache#40005)

Fixes apache#40004.

* Closes: apache#40004

Authored-by: lupko <lubomir.slivka@gooddata.com>
Signed-off-by: David Li <li.davidm96@gmail.com>
thisisnic pushed a commit to thisisnic/arrow that referenced this issue Mar 8, 2024
…pache#40005)

Fixes apache#40004.

* Closes: apache#40004

Authored-by: lupko <lubomir.slivka@gooddata.com>
Signed-off-by: David Li <li.davidm96@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: FlightRPC Component: Python Critical Fix Bugfixes for security vulnerabilities, crashes, or invalid data. Type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants