-
Notifications
You must be signed in to change notification settings - Fork 13
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
pgpubsub falls far behind after a few hours #19
Comments
Something maybe related: this issue started to happen after I added a listener on a new model which has a foreign key name that I defined to avoid db column conflicts.
This is defined as
Is it possible that pgpubsub is not handling that custom db column name, producing an exception, that re-generates the process but does not kill the old process, gradually over time accumulating duplicate processes that explain my slow down? I am going to refactor my model to avoid this foreign key rename to see if that makes the problem go away. |
@metalaureate That's a strange one. I don't have time right now to do a full investigation, but here's a couple of things I'm wondering about.
Notice that when any exception occurs when processing the Notification, we spin up a new process and then |
Thank you. I removed the Model with the foreign key and the problem has gone away. There's no stack trace for the foreign key error, but it is being raised by the I'm closing the issue since I can't reproduce it without the custom db_column name on the foreign key and I can work around that.
|
@metalaureate Hmm ok. I am now slightly worried that something isn't quite working between exception handling and closing processes, but I'm not sure |
@metalaureate I'm able to recreate the issue of an exception being raised when the ForeignKey is given a custom One possible explanation of the performance degradation you experienced is that, when an exception occurs, the stored |
Amazing you reproduced it! 💪 In my scenario the exceptions were infrequent and seemed to account for a total of about a dozen parallel processes (when I ctrl + C at terminal after this had been going on, I would get a Process terminated error about a dozen times. I wish I had posted that output). I wonder if it is an artifact of my Terminal environment (PyCharm, Mac M1) or my Mac sleeping and waking up. 🤷 Sorry not very helpful. |
By means of associating a unique identifier to each process, I did indeed confirm that when an exception is raised, the process in which the exception occurred is safely closed whilst a child process is spun open. So I think we can rule that possibility out as an explanation at least. |
Just in case you were interested, I explain here what's causing the bug you mentioned with the foreign key |
Thanks again for your package. I am currently using it to emit websocket messages on db updates for a news feed, but I notice it falls behind db updates by up to 20 to 30 minutes over several hrs (e.g. if I stop the feed row insertsion, the listener takes an additional 20-30 minutes to clear its backlog). It takes less than 100ms to process the listener handler, but over many hours the notifications fall behind. When I terminate the process, I get a very odd output showing a dozen or more processes terminating, not just the the usual
manage.py listen
process, which makes me wonder what is going on. Sorry not much information--happy to try to give you more information. I've added some extra logging to try to see what's causing it.The text was updated successfully, but these errors were encountered: