Re: Hot standby with hot_standny_feedback enabled: cancelling statement issues

Поиск
Список
Период
Сортировка
От Laurenz Albe
Тема Re: Hot standby with hot_standny_feedback enabled: cancelling statement issues
Дата
Msg-id 09ff8c81a3ecb764bbfec33baf432295a884c19e.camel@cybertec.at
обсуждение исходный текст
Список pgsql-admin
On Wed, 2020-11-25 at 16:46 +0700, Игорь Выскорко wrote:
> I'm trying to configure hot standby replica for analytics and simple backup purposes. So, I have long queries which
constantlycancelled without proper configuring.
 
> I do not want large lag on replica (more than 30 mins) so setting max_standby_streaming_delay to -1 is not my choice.
I have to avoid large lag because of analytic queries which must be run on
 
> almost fresh copy of data.
> I found the panacea (I thought I found actually) in setting hot_standby_feedback = on (I know about possible master
bloating)but it also doesn't help.
 
> Just to clarify about "simple backup purposes": it means run pg_dump in daily basis. Our database is about 250Gb
>  
> 2 test run of pg_dump failed with:
> pg_dump: Dumping the contents of table "table" failed: PQgetResult() failed.
> pg_dump: Error message from server: ERROR:  canceling statement due to conflict with recovery
> DETAIL:  User was holding a relation lock for too long.
> pg_dump: The command was: COPY...
>  
> postgres=# select * from pg_stat_database_conflicts ;
>    datid   |    datname    | confl_tablespace | confl_lock | confl_snapshot | confl_bufferpin | confl_deadlock 
> -----------+---------------+------------------+------------+----------------+-----------------+----------------
>      12445 | dbname      |                0 |          2 |              0 |               0 |              0
> 
> Not sure about what kind of lock was holding too long...
> 
> So, my questions are:
> 1. Why "hot_standby_feedback = on" is not helping?

Because is was not a conflict with a tuple deleted by VACUUM ("snapshot conflict"),
but with a lock.

ACCESS EXCLUSIVE locks are replicated, because they are necessary for safe
replication of commands like TRUNCATE or ALTER TABLE.

If you ran none of these commands on the primary, you probably have fallen
prey to "vacuum truncation", where a brief ACCESS EXCLUSIVE lock is taken on
a table so that VACUUM can truncate some empty pages from a table.

These locks don't disrupt operation on the primary, but they can conflict
with queries on the standby.

> 2. What is proper way to use replica for tasks as mine?

The best thing is to have two standbys: one for high availability that does
not lag (hot_standby = off), and one for pg_dump and queries.

You may want to read my blog on the topic:
https://www.cybertec-postgresql.com/en/streaming-replication-conflicts-in-postgresql/

Yours,
Laurenz Albe




В списке pgsql-admin по дате отправления:

Предыдущее
От: Nikhil Shetty
Дата:
Сообщение: Re: Streaming Replication replay lag
Следующее
От: Laurenz Albe
Дата:
Сообщение: Re: Streaming Replication replay lag