-
Notifications
You must be signed in to change notification settings - Fork 34
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
If I just call pg_background_launch() is that good enough for an Asynchronous call? #40
Comments
Unfortunately no. The only reason you see the background worker exiting is because it didn't send more traffic than the queue size (by default 65k, see https://github.com/vibhorkum/pg_background/blob/master/pg_background--1.0.sql#L6). If the underlying query generates more traffic it will just get blocked until some process tries to read from the message queue (which is what pg_background_result() does) and free some memory in the message queue. But even if it appears to be ok, the message queue will still be allocated and will persist in memory until you call pg_background_result. |
Excellent answer. So avoid the asynchronous attempt, and always call pg_background_result()! |
Note that there's also the The only problem with this approach is that you also won't be able to know if you hit an error or not processing the query. So unless you're happy with the query maybe failing without knowing, it makes it only usable as a last resort cleanup . |
Thank you. Unfortunately I need the Exception to bubble back up. My Linux guru sent me the notes on how to test this (forgive me, windows developer forever, new to git, etc.). |
The ESSENCE of this question is...
does it do any harm to ignore the results? Just run the code and let it finish...
Will it close things up properly when done?
I've monitored this on Linux (ps -ax) and the session appears to go away when finished.
I just want to make sure I am not creating any kind of memory leak!
The text was updated successfully, but these errors were encountered: