Koed00 / django-q

A multiprocessing distributed task queue for Django
https://django-q.readthedocs.org
MIT License
1.83k stars 285 forks source link

ERROR select_for_update cannot be used outside of a transaction when using a different database than default #732

Open joaquimds opened 11 months ago

joaquimds commented 11 months ago

There was another issue similar to this: https://github.com/Koed00/django-q/issues/434

But I believe this issue is different. It occurs in a different part of the code, here: https://github.com/Koed00/django-q/blob/master/django_q/cluster.py#L477

This can be fixed in the same way as the previous issue, with:

        database_to_use = {"using": Conf.ORM} if not Conf.HAS_REPLICA else {}
        with db.transaction.atomic(**database_to_use):