Asynchronous tasks ID sequence can exhaust
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start by locating the Task model and checking its primary-key references and migrations; the issue does not name specific files or tests. Verify what depends on numeric task IDs before changing the key. Done means Task.uuid is the UUID4 primary key, the sequence is removed, and no logic depends on numeric task IDs.
Written by the indexing model from the issue text.
Description
In some Flagsmith installs with a lot of dashboard activity and analytics turned on, the Task.id field can yield a sequence exhaustion error in Postgres:
django.db.utils.DataError: nextval: reached maximum value of sequence "task_processor_task_id_seq" (2147483647)
Although https://github.com/Flagsmith/flagsmith/pull/5358 has alleviated the accumulation of items by preventing /api/v1/flags/ from enqueuing new tasks for analytics tracking, we're bound to hit that limit eventually.
Seemingly, this only affects instances with analytics enabled. As such, a temporary fix includes:
- Upgrading Flagsmith to a version equal or newer than v2.173.1. This alone should postpone the exhaustion by many years in most installs.
- Shifting the sequence axis so it consumes negative numbers, i.e.:
ALTER SEQUENCE task_processor_task_id_seq MINVALUE -2147483648 RESTART WITH -2147483648;
Acceptance criteria
- Promote
Task.uuidto a primary key defaulting toUUID4(), dismissing a sequence entirely. Must ensure no logic depends on numeric task IDs.
- Dominant language
- Python
- Stars
- 2
- Forks
- 4
- Avg merge
- 1h 7m
- Merged PRs (30d)
- 4
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Flagsmith/flagsmith-common
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Flagsmith/flagsmith-common#250 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Flagsmith/flagsmith-common#198 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Flagsmith/flagsmith-common#254 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Flagsmith/flagsmith-common#252 ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
Flagsmith/flagsmith-common#245 ·
All issues in Flagsmith/flagsmith-common
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
modelcontextprotocol/python-sdk#3648 ·
Maintainers usually reply within 1 day
-
docs good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
VenetoStato/giorgio#6 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 70/100
EclipseFdn/open-vsx.org#13831 ·
Maintainers usually reply within 1 day