an attempt at fixing the weird deadlock issue ive been having
This commit is contained in:
parent
6495135124
commit
06bf189a33
7
tasks.py
7
tasks.py
|
@ -171,14 +171,15 @@ def delete_from_account(account_id):
|
||||||
account = Account.query.get(account_id)
|
account = Account.query.get(account_id)
|
||||||
latest_n_posts = (Post.query.with_parent(account)
|
latest_n_posts = (Post.query.with_parent(account)
|
||||||
.order_by(db.desc(Post.created_at))
|
.order_by(db.desc(Post.created_at))
|
||||||
.limit(account.policy_keep_latest))
|
.limit(account.policy_keep_latest)
|
||||||
|
.cte(name='latest'))
|
||||||
posts = (
|
posts = (
|
||||||
Post.query.with_parent(account)
|
Post.query.with_parent(account)
|
||||||
.filter(
|
.filter(
|
||||||
Post.created_at + account.policy_keep_younger <= db.func.now())
|
Post.created_at + account.policy_keep_younger <= db.func.now())
|
||||||
.except_(latest_n_posts)
|
.filter(~Post.id.in_(db.select((latest_n_posts.c.id,))))
|
||||||
.order_by(db.func.random())
|
.order_by(db.func.random())
|
||||||
.limit(100).all())
|
.limit(100).with_for_update().all())
|
||||||
|
|
||||||
eligible = None
|
eligible = None
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue