apache / apache/beam

Pipeline instances are not garbage collected

Open
#19,751 0 comments 0 reactions 0 assignees View on GitHub
bug core P3 python
Dominant language
Java
Stars
8.7k
Forks
4.7k
Avg merge
1d 20h
Merged PRs (30d)
196

Description

It seems that Apache Beam's Pipeline instances are not garbage collected, even if the pipelines are finished or cancelled and there are no references to those pipelines in the Python interpreter.

For pipelines executed in a script, this is not a problem. However, for interactive pipelines executed inside a Jupyter notebook, this limits how well we can track and remove the dependencies of those pipelines. For example, if a pipeline reads from some cache, it would be nice to be able to delete that cache once there are no references to it from pipelines or the global namespace.

The issue can be reproduced using the following script: [https://gist.github.com/ostrokach/a16556dc77c96b87fe23c2fbd8fb6346](https://gist.github.com/ostrokach/a16556dc77c96b87fe23c2fbd8fb6346).

\--\---

On further examination, turns out that this is due to the [`_PubSubReadEvaluator._subscription_cache`|https://github.com/apache/beam/blob/27bb5bc7b244809e7f6022adb2730d10204ce4d3/sdks/python/apache_beam/runners/direct/transform_evaluator.py#L418] class attribute keeping references to all `ReadFromPubSub` transforms.

Imported from Jira [BEAM-7750](https://issues.apache.org/jira/browse/BEAM-7750). Original Jira may contain additional context.
Reported by: ostrokach.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.