ankane / distribute_reads

Scale database reads to replicas in Rails

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not working on postgres 10.11

laurent-cobos opened this issue · comments

After an upgrade of to pg 10.11 I get this issue:

PG::UndefinedFunction: ERROR:  function pg_last_wal_receive_lsn() does not exist
LINE 1: SELECT CASE WHEN NOT pg_is_in_recovery() OR pg_last_wal_rece...
                                                    ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
: SELECT CASE WHEN NOT pg_is_in_recovery() OR pg_last_wal_receive_lsn() = pg_last_wal_replay_lsn() THEN 0 ELSE EXTRACT (EPOCH FROM NOW() - pg_last_xact_replay_timestamp()) END AS lag

a workaround is downgrade to postgres 10.1.
Might be caused by this line:

"pg_last_wal_receive_lsn() = pg_last_wal_replay_lsn()"

Postgres 10.11 is the default/only version provided by Heroku for the 10 series

Hey @ls-laurent-cobos, pg_last_wal_receive_lsn() should be available on all Postgres 10+ databases (Postgres docs). I'd double check your version and that it's not available in a psql console and then ask Heroku about it.

Closing due to no response