Skip to content

Do not consume task identity on add_job conflict - #623

Open
Steve0x2a wants to merge 1 commit into
graphile:mainfrom
Steve0x2a:fix/task-identity-on-conflict
Open

Do not consume task identity on add_job conflict#623
Steve0x2a wants to merge 1 commit into
graphile:mainfrom
Steve0x2a:fix/task-identity-on-conflict

Conversation

@Steve0x2a

Copy link
Copy Markdown

insert ... on conflict do nothing into _private_tasks / _private_job_queues still calls nextval() before the unique check, so every enqueue burns an integer identity. After ~2.1bn cumulative enqueues the sequence hits 2147483647 and both add_job and worker startup fail, even when the identifier table has only a handful of rows.

This changes those inserts (in add_jobs, add_job unsafe_dedupe, and getTaskDetails) to insert only missing identifiers (WHERE NOT EXISTS), so already-registered names do not consume identity. ON CONFLICT DO NOTHING is kept for the concurrent-insert race.

Reported by @perebusquets.

Fixes #619.

Insert missing task/queue identifiers only so nextval is not called when the name already exists.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_private_tasks identity consumed on every add_jobinteger sequence exhausts at 2^31 and the worker cannot start

1 participant