Skip to content

AssertionError on queueing_lock conflict when PostgreSQL lc_messages is not English #1531

@pararti

Description

@pararti

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 match

This 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
  AssertionError

Why 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

  1. Use PostgreSQL with lc_messages = ru_RU.UTF-8
  2. Define a task and enqueue a job with a specific queueing_lock
  3. Try to enqueue another job with the same queueing_lock
  4. 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.

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