Skip to content

[Python][FlightRPC] FlightServerBase is never freed, leaking the server and everything it references #50684

Description

@raulcd

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

A FlightServerBase, even after shutdown(), wait() and dropping the last user reference, doesn't seem to be completely freed. It stays alive and leaks.

Applications that create a Flight server per unit of work (one per build, per request batch, per test) accumulate one zombie server per cycle.

$ uv run python
Python 3.14.2 (main, Jan 14 2026, 19:38:07) [Clang 21.1.4 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gc
... import pyarrow.flight as fl
... 
... class Server(fl.FlightServerBase):
...     pass
... 
... for _ in range(100):
...     server = Server("grpc://127.0.0.1:0")
...     server.payload = bytearray(8 * 1024 * 1024)
...     server.shutdown()
...     server.wait()
...     del server
...     gc.collect()
... 
... print(sum(1 for o in gc.get_objects() if isinstance(o, Server)))
... 
100
>>> import pyarrow
>>> pyarrow.__version__
'25.0.0'

RSS grows ~8 MB per iteration, tracking the payload one for one. The same loop with a plain Python object instead of a Flight server keeps RSS flat and prints 0.

Without a payload the loop still leaks about 66 kB RSS and 12 to 16 MB of virtual address space per iteration. An equivalent C++ loop creating and shutting down a Flight server shows no growth, so this points at an issue in the Python bindings.

Component(s)

FlightRPC, Python

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions