Re: Add Information during standby recovery conflicts
Drouvot, Bertrand <bdrouvot@amazon.com>
From: "Drouvot, Bertrand" <bdrouvot@amazon.com>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Masahiko Sawada <sawada.mshk@gmail.com>, Fujii Masao <masao.fujii@oss.nttdata.com>, Masahiko Sawada <masahiko.sawada@2ndquadrant.com>, Kyotaro Horiguchi <horikyota.ntt@gmail.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2020-11-28T11:08:24Z
Lists: pgsql-hackers
Attachments
- v9-0005-Log-the-standby-recovery-conflict-waits.patch (text/plain) patch v9-0005
Hi,
On 11/27/20 2:40 PM, Alvaro Herrera wrote:
> On 2020-Nov-27, Drouvot, Bertrand wrote:
>
>> + if (nprocs > 0)
>> + {
>> + ereport(LOG,
>> + (errmsg("%s after %ld.%03d ms",
>> + get_recovery_conflict_desc(reason), msecs, usecs),
>> + (errdetail_log_plural("Conflicting process: %s.",
>> + "Conflicting processes: %s.",
>> + nprocs, buf.data))));
>> + }
>> +/* Return the description of recovery conflict */
>> +static const char *
>> +get_recovery_conflict_desc(ProcSignalReason reason)
>> +{
>> + const char *reasonDesc = gettext_noop("unknown reason");
>> +
>> + switch (reason)
>> + {
>> + case PROCSIG_RECOVERY_CONFLICT_BUFFERPIN:
>> + reasonDesc = gettext_noop("recovery is still waiting for recovery conflict on buffer pin");
>> + break;
> This doesn't work from a translation point of view. First, you're
> building a sentence from parts, which is against policy. Second, you're
> not actually invoking gettext to translate the string returned by
> get_recovery_conflict_desc.
>
> I think this needs to be rethought. To handle the first problem I
> suggest to split the error message in two. One phrase is the complain
> that recovery is waiting, and the other string is the reason for the
> wait. Separate both either by splitting with a :, or alternatively put
> the other sentence in DETAIL. (The latter would require to mix with the
> list of conflicting processes, which might be hard.)
>
> The first idea would look like this:
>
> LOG: recovery still waiting after %ld.03d ms: for recovery conflict on buffer pin
> DETAIL: Conflicting processes: 1, 2, 3.
>
> To achieve this, apart from editing the messages returned by
> get_recovery_conflict_desc, you'd need to ereport this way:
>
> ereport(LOG,
> errmsg("recovery still waiting after %ld.%03d ms: %s",
> msecs, usecs, _(get_recovery_conflict_desc(reason))),
> errdetail_log_plural("Conflicting process: %s.",
> "Conflicting processes: %s.",
>
Thanks for your comments, I did not know that.
I've attached a new version that takes your comments into account.
Thanks!
Bertrand
Commits
-
Log long wait time on recovery conflict when it's resolved.
- 39b03690b529 14.0 landed
-
Add GUC to log long wait times on recovery conflicts.
- 0650ff23038b 14.0 landed
-
Detect the deadlocks between backends and the startup process.
- 8900b5a9d59a 14.0 cited
-
Get rid of the dedicated latch for signaling the startup process.
- ac22929a2613 14.0 cited
-
Add block information in error context of WAL REDO apply loop
- 9d0bd95fa90a 14.0 cited