Skip to content

Getting exception "select_for_update cannot be used outside of a transaction" #422

@rehbarkhan

Description

@rehbarkhan

django-celery-results is not able to save the tasks results, getting below error. :

{"exc_type": "TransactionManagementError", "exc_message": ["select_for_update cannot be used outside of a transaction."], "exc_module": "django.db.transaction"}

My App Config:

  • django==4.2.*
  • django-celery-beat==2.5.0
  • django-celery-results==2.5.1

My database config:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'production',
        'USER': 'production_user',
        'PASSWORD': env('MYSQL_PASSWORD'),
        'HOST': env('MYSQL_HOST'),
        'CONN_MAX_AGE': 600,
        # 'ATOMIC_REQUESTS': True,
    }
}

DATABASES['production_db'] = DATABASES['default']

I have tried to enable "ATOMIC_REQUESTS: True" but no luck, still getting the TransactionManagementError

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions