Update counts using single task and PostgreSQL notification channel#5868
Update counts using single task and PostgreSQL notification channel#5868dullbananas wants to merge 4 commits intoLemmyNet:mainfrom
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