-
-
Notifications
You must be signed in to change notification settings - Fork 936
Update counts using single task and PostgreSQL notification channel #5868
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
base: main
Are you sure you want to change the base?
Conversation
|
Before you get too far with this, does this mean moving away from table triggers, and having the count-related actions be backgrounded? I'm wondering how safe/reliable this would be when you have multiple updates, and the triggers aren't holding any locks anymore. |
|
I might either:
Either way, it's easy to guarantee that no increment or decrement is duplicated or permanently skipped. Counter updates in response to inserts and updates updates will involve doing one of the following atomically:
Deletion of rows needs to be handled very differently, but will still be reliable. What I will probably do is make purges use update instead of delete, and delete the rows in the background task. |
|
How is this going to work if an instance uses multiple Lemmy processes? |
|
Just to give my input after doing a ton of this bulk insert / update work... Triggers can and do work well, I think we just need to optimize them to make sure they're limited to specific column updates, and don't necessarily fire on every insert or delete. Also to do as few joins as possible, and only increment or decrement by 1. I'm not sure that any of the |
If an instance is correctly configured, then exactly one process updates counts, because the task is started by The notification channel is not affected by whether or not the sending side and the receiving side are associated with the same Lemmy process.
All three will be updated in the same transaction. |
|
Actually, the report count case might require an additional |
Requires weiznich/diesel_async#251