Skip to content

Allow pause/resuming all pools #566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 29, 2023
Merged

Conversation

tommyzli
Copy link
Contributor

Hi - this updates the behaviour of PAUSE and RESUME to more closely match pgbouncers. A simple PAUSE; or RESUME; statement will now affect all pools. The previous behaviour of PAUSE db,user; is still supported and will only affect a single pool.

I'd like to use pgcat to replace some pgbouncers that have many pools, and being able to pause them all with one command would go a long way in simplifying the operations :)
example:

pgcat=> show databases;
           name            |   host    | port | database  | force_user | pool_size | min_pool_size | reserve_pool |  pool_mode  | max_connections | current_connections | paused | disabled
---------------------------+-----------+------+-----------+------------+-----------+---------------+--------------+-------------+-----------------+---------------------+--------+----------
 test_db_1_shard_0_primary | 127.0.0.1 | 5432 | postgres  | postgres   |        10 |             0 |            0 | transaction |              10 |                   1 |      0 |        0
 test_db_2_shard_0_primary | 127.0.0.1 | 5432 | template1 | postgres   |        10 |             0 |            0 | transaction |              10 |                   1 |      0 |        0
(2 rows)

pgcat=> pause;
PAUSE
pgcat=> show databases;
           name            |   host    | port | database  | force_user | pool_size | min_pool_size | reserve_pool |  pool_mode  | max_connections | current_connections | paused | disabled
---------------------------+-----------+------+-----------+------------+-----------+---------------+--------------+-------------+-----------------+---------------------+--------+----------
 test_db_1_shard_0_primary | 127.0.0.1 | 5432 | postgres  | postgres   |        10 |             0 |            0 | transaction |              10 |                   1 |      1 |        0
 test_db_2_shard_0_primary | 127.0.0.1 | 5432 | template1 | postgres   |        10 |             0 |            0 | transaction |              10 |                   1 |      1 |        0
(2 rows)

pgcat=> resume;
RESUME
pgcat=> show databases;
           name            |   host    | port | database  | force_user | pool_size | min_pool_size | reserve_pool |  pool_mode  | max_connections | current_connections | paused | disabled
---------------------------+-----------+------+-----------+------------+-----------+---------------+--------------+-------------+-----------------+---------------------+--------+----------
 test_db_1_shard_0_primary | 127.0.0.1 | 5432 | postgres  | postgres   |        10 |             0 |            0 | transaction |              10 |                   1 |      0 |        0
 test_db_2_shard_0_primary | 127.0.0.1 | 5432 | template1 | postgres   |        10 |             0 |            0 | transaction |              10 |                   1 |      0 |        0
(2 rows)

pgcat=> pause test_db_1,postgres;
PAUSE test_db_1,postgres
pgcat=> show databases;
           name            |   host    | port | database  | force_user | pool_size | min_pool_size | reserve_pool |  pool_mode  | max_connections | current_connections | paused | disabled
---------------------------+-----------+------+-----------+------------+-----------+---------------+--------------+-------------+-----------------+---------------------+--------+----------
 test_db_1_shard_0_primary | 127.0.0.1 | 5432 | postgres  | postgres   |        10 |             0 |            0 | transaction |              10 |                   1 |      1 |        0
 test_db_2_shard_0_primary | 127.0.0.1 | 5432 | template1 | postgres   |        10 |             0 |            0 | transaction |              10 |                   1 |      0 |        0
(2 rows)

pgcat=> resume;
RESUME
pgcat=> show databases;
           name            |   host    | port | database  | force_user | pool_size | min_pool_size | reserve_pool |  pool_mode  | max_connections | current_connections | paused | disabled
---------------------------+-----------+------+-----------+------------+-----------+---------------+--------------+-------------+-----------------+---------------------+--------+----------
 test_db_1_shard_0_primary | 127.0.0.1 | 5432 | postgres  | postgres   |        10 |             0 |            0 | transaction |              10 |                   1 |      0 |        0
 test_db_2_shard_0_primary | 127.0.0.1 | 5432 | template1 | postgres   |        10 |             0 |            0 | transaction |              10 |                   1 |      0 |        0
(2 rows)

@levkk
Copy link
Contributor

levkk commented Aug 29, 2023

Really cool, thanks!

@levkk levkk merged commit 9937193 into postgresml:main Aug 29, 2023
@tommyzli tommyzli deleted the blanket-pause branch August 29, 2023 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants