Re: Improve error messages for database object stats manipulation functions during recovery

Lists: pgsql-hackers
From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Improve error messages for database object stats manipulation functions during recovery
Date: 2024-10-25 17:07:44
Message-ID: 6d313829-5f56-4a28-ae4b-bd01bf1ae791@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

When database object stats manipulation functions like pg_set_relation_stats() are run,
they currently produce the following error and hint messages, which are "internal"
and make it hard for users to understand the issue:

ERROR: cannot acquire lock mode ShareUpdateExclusiveLock on database objects while recovery is in progress
HINT: Only RowExclusiveLock or less can be acquired on database objects during recovery.

So I'd like to propose updating these to clearer messages:

ERROR: recovery is in progress
HINT: Database object statistics manipulation functions cannot be executed during recovery.

Thought?

I've attached a patch implementing these changes. It also updates the documentation to
clearly state that these functions are not available during recovery.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

Attachment Content-Type Size
v1-0001-Improve-error-message-for-database-object-stats-m.patch text/plain 3.7 KB

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Improve error messages for database object stats manipulation functions during recovery
Date: 2024-11-12 21:09:58
Message-ID: 0340699e-2501-4d45-bd7b-7ed353974dcb@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 25/10/2024 20:07, Fujii Masao wrote:
> Hi,
>
> When database object stats manipulation functions like
> pg_set_relation_stats() are run,
> they currently produce the following error and hint messages, which are
> "internal"
> and make it hard for users to understand the issue:
>
>       ERROR:  cannot acquire lock mode ShareUpdateExclusiveLock on
> database objects while recovery is in progress
>       HINT:  Only RowExclusiveLock or less can be acquired on database
> objects during recovery.
>
> So I'd like to propose updating these to clearer messages:
>
>       ERROR:  recovery is in progress
>       HINT:  Database object statistics manipulation functions cannot
> be executed during recovery.
>
> Thought?

Makes sense.

"Database object statistics manipulation functions" is a bit of a
mouthful". Maybe something like "statistics cannot be modified during
recovery".

> I've attached a patch implementing these changes. It also updates the
> documentation to
> clearly state that these functions are not available during recovery.

Looks good to me.

--
Heikki Linnakangas
Neon (https://neon.tech)


From: Maxim Orlov <orlovmg(at)gmail(dot)com>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Improve error messages for database object stats manipulation functions during recovery
Date: 2024-11-15 11:59:00
Message-ID: CACG=ezYWvxrsLw3eChPKhiPG87Bf2e+LLp4hLNO7surLv7x7XA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

+1 for the patch.

Recently, one of our customer have tried to upgrade the replica, and,
obviously, failed. I don't remember the exact error message, but for him it
was not so clear that server is in recovery. Explicitly declaring error is
the way to go in my view.

So, I consider this patch useful. Overall, looks good to me.

--
Best regards,
Maxim Orlov.


From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Improve error messages for database object stats manipulation functions during recovery
Date: 2024-11-15 17:36:54
Message-ID: 51c5fc9e-e234-491a-ab3c-5a882bec31f7@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2024/11/13 6:09, Heikki Linnakangas wrote:
> On 25/10/2024 20:07, Fujii Masao wrote:
>> Hi,
>>
>> When database object stats manipulation functions like pg_set_relation_stats() are run,
>> they currently produce the following error and hint messages, which are "internal"
>> and make it hard for users to understand the issue:
>>
>>        ERROR:  cannot acquire lock mode ShareUpdateExclusiveLock on database objects while recovery is in progress
>>        HINT:  Only RowExclusiveLock or less can be acquired on database objects during recovery.
>>
>> So I'd like to propose updating these to clearer messages:
>>
>>        ERROR:  recovery is in progress
>>        HINT:  Database object statistics manipulation functions cannot be executed during recovery.
>>
>> Thought?
>
> Makes sense.
>
> "Database object statistics manipulation functions" is a bit of a mouthful". Maybe something like "statistics cannot be modified during recovery".

Sounds good! I've updated the hint messages as suggested and attached the revised patch.
Thanks for the review!

Unless there are any objections, I'll proceed with committing it.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

Attachment Content-Type Size
v2-0001-Improve-error-message-for-database-object-stats-m.patch text/plain 3.7 KB

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: Maxim Orlov <orlovmg(at)gmail(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Improve error messages for database object stats manipulation functions during recovery
Date: 2024-11-15 17:37:16
Message-ID: e33e7a8a-6f79-47b0-ad3e-85bab93f6bca@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2024/11/15 20:59, Maxim Orlov wrote:
> +1 for the patch.
>
> Recently, one of our customer have tried to upgrade the replica, and, obviously, failed. I don't remember the exact error message, but for him it was not so clear that server is in recovery. Explicitly declaring error is the way to go in my view.
>
> So, I consider this patch useful. Overall, looks good to me.

Thanks for the review!

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION


From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Improve error messages for database object stats manipulation functions during recovery
Date: 2024-11-19 17:04:06
Message-ID: ced0ffe6-f90f-490b-befe-fdd92bccdaee@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2024/11/16 2:36, Fujii Masao wrote:
> Sounds good! I've updated the hint messages as suggested and attached the revised patch.
> Thanks for the review!
>
> Unless there are any objections, I'll proceed with committing it.

Pushed. Thanks!

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION