[ pg_ctl ] Review Request for Adding Pre-check User Script Feature

Started by 김명준over 2 years ago4 messageshackers

Thread notes

1 note#feature#moderate
hackorum-bot#feature#moderate
hackorum-bot
1 day ago

@global #feature #moderate

#feature#moderate
Jump to latest
#1김명준
rayjun0525@gmail.com

Hello,

I have been considering adding a user script that performs pre-checks
before executing the start, stop, and restart operations in pg_ctl. I
believe it is necessary for pg_ctl to support an extension that can prevent
various issues that might occur when using start and stop. To this end, I
have sought a way for users to define and use their own logic. The existing
behavior remains unchanged, and the feature can be used optionally when
needed.

The verification of the code was carried out using the methods described
below, and I would like to request additional opinions or feedback. Tests
were conducted using make check and through direct testing under various
scenarios. As this is my first contribution, there might be aspects I
missed or incorrectly designed.

I would appreciate it if you could review this.

Thank you.

Myoungjun Kim / South Korea

Attachments:

t49966_1
pg_ctl_user_script.patchapplication/octet-stream; name=pg_ctl_user_script.patchDownload+102-14
#2Zaid Shabbir
zaidshabbir@gmail.com
In reply to: 김명준 (#1)
Re: [ pg_ctl ] Review Request for Adding Pre-check User Script Feature

Hello,

Can you briefly explain what’s the issues you are going through the patch?

On Tue, 16 Jul 2024 at 11:40 AM, 김명준 <rayjun0525@gmail.com> wrote:

Show quoted text

Hello,

I have been considering adding a user script that performs pre-checks
before executing the start, stop, and restart operations in pg_ctl. I
believe it is necessary for pg_ctl to support an extension that can prevent
various issues that might occur when using start and stop. To this end, I
have sought a way for users to define and use their own logic. The existing
behavior remains unchanged, and the feature can be used optionally when
needed.

The verification of the code was carried out using the methods described
below, and I would like to request additional opinions or feedback. Tests
were conducted using make check and through direct testing under various
scenarios. As this is my first contribution, there might be aspects I
missed or incorrectly designed.

I would appreciate it if you could review this.

Thank you.

Myoungjun Kim / South Korea

#3Kisoon Kwon
moxie2ks@gmail.com
In reply to: 김명준 (#1)
Re: [ pg_ctl ] Review Request for Adding Pre-check User Script Feature

Hi,

0. For more understanding, can you give me an example about your patch?
1. Instead of using chmod itself, it would be better to
use chmod_recursive().
2. It needs to follow the invent convention - it includes 4 spaces now.

Thank you,

Kisoon Kwon

2024년 7월 16일 (화) 오후 3:40, 김명준 <rayjun0525@gmail.com>님이 작성:

Show quoted text

Hello,

I have been considering adding a user script that performs pre-checks
before executing the start, stop, and restart operations in pg_ctl. I
believe it is necessary for pg_ctl to support an extension that can prevent
various issues that might occur when using start and stop. To this end, I
have sought a way for users to define and use their own logic. The existing
behavior remains unchanged, and the feature can be used optionally when
needed.

The verification of the code was carried out using the methods described
below, and I would like to request additional opinions or feedback. Tests
were conducted using make check and through direct testing under various
scenarios. As this is my first contribution, there might be aspects I
missed or incorrectly designed.

I would appreciate it if you could review this.

Thank you.

Myoungjun Kim / South Korea

#4김명준
rayjun0525@gmail.com
In reply to: Kisoon Kwon (#3)
Re: [ pg_ctl ] Review Request for Adding Pre-check User Script Feature

Hello,

Thank you for your response.

0. Here is an example of what I intended.
What I intended is to add pre-check tasks before executing pg_ctl start,
stop, and restart using the -A and -Z options.

=========================================
[test@test]$ cat true.sh
#!/bin/bash
echo 'true'
exit 0
=========================================
[test@test]$ cat false.sh
#!/bin/bash
echo 'false'
exit 1
=========================================
[test@test]$ pg_ctl start -A false.sh
false
pg_ctl: pre-check for start failed, aborting start
=========================================
[test@test]$ pg_ctl start -A true.sh
true
waiting for server to start....2024-07-19 00:16:22.768 UTC [167505] LOG:
starting PostgreSQL 18devel on
~
~
done
server started
=========================================
[test@test]$ pg_ctl stop -Z false.sh
false
pg_ctl: pre-check for stop failed, aborting stop
=========================================
[test@test]$ pg_ctl stop -Z true.sh
true
waiting for server to shut down....2024-07-19 00:21:06.282 UTC [167515]
LOG: received fast shutdown request
~
~
done
server stopped
=========================================
[test@test]$ pg_ctl restart -A false.sh -Z false.sh
false
pg_ctl: pre-check script for stop failed, aborting stop
=========================================
[test@test]$ pg_ctl restart -A false.sh -Z true.sh
true
waiting for server to shut down...2024-07-19 00:24:39.640 UTC [167530] LOG:
received fast shutdown request
~
~
done
server stopped
false
pg_ctl: pre-check script for start failed, aborting start
=========================================

1. I plan to change it to chmod_recursive() instead of using chmod itself.
2. I will modify it to use 4 spaces instead of a tab.

Thank you,

Myoungjun Kim

2024년 7월 16일 (화) 오후 5:26, Kisoon Kwon <moxie2ks@gmail.com>님이 작성:

Show quoted text

Hi,

0. For more understanding, can you give me an example about your patch?
1. Instead of using chmod itself, it would be better to
use chmod_recursive().
2. It needs to follow the invent convention - it includes 4 spaces now.

Thank you,

Kisoon Kwon

2024년 7월 16일 (화) 오후 3:40, 김명준 <rayjun0525@gmail.com>님이 작성:

Hello,

I have been considering adding a user script that performs pre-checks
before executing the start, stop, and restart operations in pg_ctl. I
believe it is necessary for pg_ctl to support an extension that can prevent
various issues that might occur when using start and stop. To this end, I
have sought a way for users to define and use their own logic. The existing
behavior remains unchanged, and the feature can be used optionally when
needed.

The verification of the code was carried out using the methods described
below, and I would like to request additional opinions or feedback. Tests
were conducted using make check and through direct testing under various
scenarios. As this is my first contribution, there might be aspects I
missed or incorrectly designed.

I would appreciate it if you could review this.

Thank you.

Myoungjun Kim / South Korea