-
-
Notifications
You must be signed in to change notification settings - Fork 87
Description
Hi,
I ran into an issue with queueing_lock handling when PostgreSQL uses a non-English locale for server messages.
What happened
When a second job is enqueued with the same queueing_lock, Procrastinate is expected to raise AlreadyEnqueued.
Instead, it crashes with an AssertionError inside sync_psycopg_connector.wrap_exceptions().
The failure happens here:
match = re.search(r"Key \((.*?)\)=\((.*?)\)", exc.diag.message_detail)
assert matchThis seems to assume that exc.diag.message_detail is always in English.
Environment
- Procrastinate: 3.7.2
- psycopg: 3.3.3
- PostgreSQL: 17.8
- lc_messages = ru_RU.UTF-8
Expected behavior
A queueing lock conflict should raise procrastinate.exceptions.AlreadyEnqueued, regardless of PostgreSQL message locale.
Actual behavior
Procrastinate raises AssertionError while trying to parse the localized message_detail.
Stack trace
File ".../procrastinate/psycopg_connector.py", line 52, in wrap_exceptions
with sync_psycopg_connector.wrap_exceptions():
File ".../procrastinate/sync_psycopg_connector.py", line 36, in wrap_exceptions
assert match
AssertionErrorWhy this is a problem
On installations where PostgreSQL uses a localized lc_messages, duplicate enqueue with queueing_lock becomes an internal library error instead of a normal AlreadyEnqueued flow.
Reproduction idea
- Use PostgreSQL with lc_messages = ru_RU.UTF-8
- Define a task and enqueue a job with a specific queueing_lock
- Try to enqueue another job with the same queueing_lock
- Observe AssertionError instead of AlreadyEnqueued
Note
In our case this happens on a shared PostgreSQL instance, so changing lc_messages is not a practical workaround.
It looks like parsing localized message_detail is too fragile here.