citusdata / citusdata/django-multitenant

Celery compatibility issue

Open
#213 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
823
Forks
126
PR merge metrics
No merged PRs in 30d

Description

I'm using django-multitenant together with Celery and a Redis broker.

I've added a tenant_id parameter to all my celery functions. When the tasks start it calls 'set_current_tenant' with this tenant ID.

In one case I forgot to call 'set_current_tenant', however, it used the tenant_id of the task that was last ran. It is as if it remembered the tenant_id of another task that another user (of another tenant) ran.

I thought that this shouldn't be possible, so I'm worried about potential unintended consequences this may have, such as race conditions.

Is this project compatible with Celery and if so, is there any particular configuration I should do?

Contributor guide

Open the contributing guide

Research direction

No files, tests, or entry points are named. Start by reproducing the missing set_current_tenant case with Celery and Redis, then trace whether tenant context persists between tasks; done means confirming the behavior and identifying the required configuration or isolation fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python, redis
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.