NAME

Punk::Observe::Backend::Pg - configuration in PostgreSQL

SYNOPSIS

plugin 'Observe' => {
    guard => 'Web::Auth#observe_admin',
    store => '/var/lib/punk-observe',
    db    => 'dbi:Pg:dbname=observe;host=db.internal',
};

DESCRIPTION

For an installation that already runs PostgreSQL and would rather have one database than two. Punk::Observe::Backend::SQLite is the default, and is the better answer for a single node.

Requires DBD::Pg, which this distribution does not depend on - it is loaded only when a dbi:Pg: dsn asks for it, so an installation using the default never needs it installed.

The lock is advisory

PostgreSQL has a real advisory lock, so migrate takes one rather than making the transaction do double duty as SQLite must. It is session-scoped rather than transaction-scoped on purpose: the caller may already own a transaction, and pg_advisory_xact_lock would then release at their commit rather than at the end of the migration.

It is released whatever happens, including on failure. A leaked lock here is a boot that hangs forever next time, which is worse than whatever caused it.

METHODS

Everything is inherited from Punk::Observe::Backend. This class exists to say what the dialect needs.

MIGRATE_LOCK

The advisory lock key, a constant so that two processes agree on it without coordinating. It fits a 32-bit IV deliberately: pg_advisory_lock takes a bigint, but several supported perls have a 32-bit IV where a larger constant becomes an NV and reaches DBI as a float - taking the lock on a different key, on exactly the platforms nobody tests interactively.

SEE ALSO

Punk::Observe::Backend

AUTHOR

LNATION, <email at lnation.org>

LICENSE AND COPYRIGHT

This software is Copyright (c) 2026 by LNATION.

This is free software, licensed under the Artistic License 2.0.