pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedReindex "locked" standby database
5+ messages / 3 participants
[nested] [flat]
* Reindex "locked" standby database
@ 2021-12-15 03:15 Martín Fernández <fmartin91@gmail.com>
2021-12-15 03:37 ` Re: Reindex "locked" standby database Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 5+ messages in thread
From: Martín Fernández @ 2021-12-15 03:15 UTC (permalink / raw)
To: pgsql-general
Hello pg hackers!
Today we had to run a `REINDEX table CONCURRENTLY my_table;` in our production database due to considerable index bloat. We used to deal with this problem in the past by using pg_repack but we stopped using it because our data replication tool doesn’t support “re creating” tables in the way that pg_repack does it (we are using Fivetran).
The reindex went fine in the primary database and in one of our standby. The other standby that we also operate for some reason ended up in a state where all transactions were locked by the WAL process and the WAL process was not able to make any progress. In order to solve this issue we had to move traffic from the “bad” standby to the healthy one and then kill all transactions that were running in the “bad” standby. After that, replication was able to resume successfully.
I’m just trying to understand what could have caused this issue. I was not able to identify any queries in the standby that would be locking the WAL process. Any insight would be more than welcome!
We are running pg12 in our cluster and standbys are replicating using physical replication lots.
Best,
Martín
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Reindex "locked" standby database
2021-12-15 03:15 Reindex "locked" standby database Martín Fernández <fmartin91@gmail.com>
@ 2021-12-15 03:37 ` Michael Paquier <michael@paquier.xyz>
2021-12-15 03:52 ` Re: Reindex "locked" standby database Mladen Gogala <gogala.mladen@gmail.com>
2021-12-15 04:10 ` Re: Reindex "locked" standby database Martín Fernández <fmartin91@gmail.com>
0 siblings, 2 replies; 5+ messages in thread
From: Michael Paquier @ 2021-12-15 03:37 UTC (permalink / raw)
To: Martín Fernández <fmartin91@gmail.com>; +Cc: pgsql-general
On Wed, Dec 15, 2021 at 12:15:27AM -0300, Martín Fernández wrote:
> The reindex went fine in the primary database and in one of our
> standby. The other standby that we also operate for some reason
> ended up in a state where all transactions were locked by the WAL
> process and the WAL process was not able to make any progress. In
> order to solve this issue we had to move traffic from the “bad”
> standby to the healthy one and then kill all transactions that were
> running in the “bad” standby. After that, replication was able to
> resume successfully.
You are referring to the startup process that replays WAL, right?
Without having an idea about the type of workload your primary and/or
standbys are facing, as well as an idea of the configuration you are
using on both (hot_standby_feedback for one), I have no direct idea,
but that could be a conflict caused by a concurrent vacuum.
Seeing where things got stuck could also be useful, perhaps with a
backtrace of the area where it happens and some information around
it.
> I’m just trying to understand what could have caused this issue. I
> was not able to identify any queries in the standby that would be
> locking the WAL process. Any insight would be more than welcome!
That's not going to be easy without more information, I am afraid.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Reindex "locked" standby database
2021-12-15 03:15 Reindex "locked" standby database Martín Fernández <fmartin91@gmail.com>
2021-12-15 03:37 ` Re: Reindex "locked" standby database Michael Paquier <michael@paquier.xyz>
@ 2021-12-15 03:52 ` Mladen Gogala <gogala.mladen@gmail.com>
2021-12-15 04:20 ` Re: Reindex "locked" standby database Martín Fernández <fmartin91@gmail.com>
1 sibling, 1 reply; 5+ messages in thread
From: Mladen Gogala @ 2021-12-15 03:52 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 12/14/21 22:37, Michael Paquier wrote:
> You are referring to the startup process that replays WAL, right?
> Without having an idea about the type of workload your primary and/or
> standbys are facing, as well as an idea of the configuration you are
> using on both (hot_standby_feedback for one), I have no direct idea,
> but that could be a conflict caused by a concurrent vacuum.
Hi Michael,
I am preparing for a standby deployment. I don't have a standby yet and,
therefore, I don't have any standby problems. Would it be advisable to
turn vacuum off on the standby? Applying WAL will also, in theory,
populate the statistics which is also held in the database blocks.
Regards
--
Mladen Gogala
Database Consultant
Tel: (347) 321-1217
https://dbwhisperer.wordpress.com
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Reindex "locked" standby database
2021-12-15 03:15 Reindex "locked" standby database Martín Fernández <fmartin91@gmail.com>
2021-12-15 03:37 ` Re: Reindex "locked" standby database Michael Paquier <michael@paquier.xyz>
2021-12-15 03:52 ` Re: Reindex "locked" standby database Mladen Gogala <gogala.mladen@gmail.com>
@ 2021-12-15 04:20 ` Martín Fernández <fmartin91@gmail.com>
0 siblings, 0 replies; 5+ messages in thread
From: Martín Fernández @ 2021-12-15 04:20 UTC (permalink / raw)
To: Mladen Gogala <gogala.mladen@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
> On 15 Dec 2021, at 00:52, Mladen Gogala <gogala.mladen@gmail.com> wrote:
>
> On 12/14/21 22:37, Michael Paquier wrote:
>> You are referring to the startup process that replays WAL, right?
>> Without having an idea about the type of workload your primary and/or
>> standbys are facing, as well as an idea of the configuration you are
>> using on both (hot_standby_feedback for one), I have no direct idea,
>> but that could be a conflict caused by a concurrent vacuum.
>
> Hi Michael,
>
> I am preparing for a standby deployment. I don't have a standby yet and, therefore, I don't have any standby problems. Would it be advisable to turn vacuum off on the standby? Applying WAL will also, in theory, populate the statistics which is also held in the database blocks.
Take this with grain of salt since I’m far from being an expert :) , just trying to help. To my knowledge, assuming you would be running a physical standby, vacuum operations wouldn’t run there, only in the primary. Changes would get propagated via physical replication to your standby (blocks that change due to vacuuming on the primary).
Hope that helps.
>
> Regards
>
> --
> Mladen Gogala
> Database Consultant
> Tel: (347) 321-1217
> https://dbwhisperer.wordpress.com
>
>
>
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Reindex "locked" standby database
2021-12-15 03:15 Reindex "locked" standby database Martín Fernández <fmartin91@gmail.com>
2021-12-15 03:37 ` Re: Reindex "locked" standby database Michael Paquier <michael@paquier.xyz>
@ 2021-12-15 04:10 ` Martín Fernández <fmartin91@gmail.com>
1 sibling, 0 replies; 5+ messages in thread
From: Martín Fernández @ 2021-12-15 04:10 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: pgsql-general
Micheal,
Thanks for much for the quick response.
> On 15 Dec 2021, at 00:37, Michael Paquier <michael@paquier.xyz> wrote:
>
> On Wed, Dec 15, 2021 at 12:15:27AM -0300, Martín Fernández wrote:
>> The reindex went fine in the primary database and in one of our
>> standby. The other standby that we also operate for some reason
>> ended up in a state where all transactions were locked by the WAL
>> process and the WAL process was not able to make any progress. In
>> order to solve this issue we had to move traffic from the “bad”
>> standby to the healthy one and then kill all transactions that were
>> running in the “bad” standby. After that, replication was able to
>> resume successfully.
>
> You are referring to the startup process that replays WAL, right?
That is correct, I’m talking about the startup process that replays the WAL files.
> Without having an idea about the type of workload your primary and/or
> standbys are facing, as well as an idea of the configuration you are
> using on both (hot_standby_feedback for one), I have no direct idea,
Primary handle IOT data ingestion. The table that we had to REINDEX gets updated every time a new message arrives in the system so updated are happening very often on that table, thus, the index/table bloat. The standby at any point in time would be receiving queries that would take advantage of the indexes that were being re indexed. hot_standby_feedback is currently turned OFF on the standbys.
> but that could be a conflict caused by a concurrent vacuum.
>
> Seeing where things got stuck could also be useful, perhaps with a
> backtrace of the area where it happens and some information around
> it.
>
>> I’m just trying to understand what could have caused this issue. I
>> was not able to identify any queries in the standby that would be
>> locking the WAL process. Any insight would be more than welcome!
>
> That's not going to be easy without more information, I am afraid.
> --
> Michael
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2021-12-15 04:20 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-12-15 03:15 Reindex "locked" standby database Martín Fernández <fmartin91@gmail.com>
2021-12-15 03:37 ` Michael Paquier <michael@paquier.xyz>
2021-12-15 03:52 ` Mladen Gogala <gogala.mladen@gmail.com>
2021-12-15 04:20 ` Martín Fernández <fmartin91@gmail.com>
2021-12-15 04:10 ` Martín Fernández <fmartin91@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox