Skip to content

BackgroundConsumer destruction issues #788

@daniel-sanche

Description

@daniel-sanche

We recently merged a PR that clears some variables that were causing a memory leak in the bidirectional streaming classes. It seems like after getting that fix in, it exposed a deeper issue: the background thread isn't exiting as expected.

Quick Fix

When this happens, it's leading to a null pointer exception here, now that the _on_response can be empty. So as a quick fix, we should add a None check there

Deeper Issue

The root issue is that the BackgroundConsumer's background thread is getting stuck calling _on_response while being torn down. In the case of Firestore, it looks like the deadlock is the fault of the Watch class, which tries to re-enter a lock. But I think we should consider changing the BackgroundConsumer to close quicker, without doing that final on_response call at all. Is it really necessary to call that callback while being closed?

More Context

googleapis/python-firestore#985 (comment)

Let me know if you want me to submit a PR

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy