Skip to content

Silent infinite wait with Postgres and blocking: true despite timeout being specified #147

Description

@bbascarevic

WithAdvisoryLock is silently ignoring the timeout_seconds parameter when blocking option is set to true. There's no warning or indication. The only clue is in-code comment:

timeout_seconds is accepted for compatibility but ignored - PostgreSQL doesn't support native timeouts with pg_try_advisory_lock, requiring Ruby-level polling instead

Postgres does support timeouts if session-level lock_timeout is set, which is what IMO should be used when blocking is used in combination with a timeout. Also, blocking: true && timeout_seconds&.zero? should use the try_ family of functions (effectively blocking should be ignored if timeout is explicitly zero).

If this is not possible or wanted, consider at least adding a warn statement if timeout is specified along with blocking.

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