Re: [PATCH] vacuumdb: Add --exclude-database option
Re: [PATCH] vacuumdb: Add --exclude-database option
От:
Japin Li <japinli@hotmail.com>
Дата:
Hi, Mohamed On Tue, 09 Jun 2026 at 23:24, Mohamed ALi wrote: > Hi Quan, wenhui, > > Thanks for the review and feedback. > > On Thu, Jun 5, 2026 at 09:25:52 AM, Quan Zongliang wrote: >> In the vacuum_all_databases function. If the condition 'if >> (dbsToExclude)' is used. All 'exclude-database' processing (including >> variable definitions) can be placed in a separate code block. > > Good suggestion. Attached is v2 incorporating this change, the > exclude-database logic (including the `cell` and `first` variable > declarations) is now scoped inside an `if (dbsToExclude)` block. > This keeps the variables out of the function's top-level scope when > the feature isn't being used. > > > The patch is also tracked in CommitFest PG20-1: > https://commitfest.postgresql.org/patch/6833/ Thanks for updating the patch. I have one question. +$node->command_fails_like( + [ 'vacuumdb', '-d' => 'postgres', '--exclude-database' => 'regression_excl_test' ], + qr/cannot use --exclude-database without --all option/, + 'cannot use --exclude-database with -d'); The test is a bit confusing to me. It does not state that --exclude-database cannot be used with the -d option. > > -- > Mohamed Ali > AWS RDS -- Regards, Japin Li ChengDu WenWu Information Technology Co., Ltd.
Re: [PATCH] vacuumdb: Add --exclude-database option
Hi Japin,
Thanks for the review.
On Tue, Jun 10, 2026 at 09:39:16 AM, Japin Li wrote:
> +$node->command_fails_like(
> + [ 'vacuumdb', '-d' => 'postgres', '--exclude-database' => 'regression_excl_test' ],
> + qr/cannot use --exclude-database without --all option/,
> + 'cannot use --exclude-database with -d');
>
> The test is a bit confusing to me. It does not state that
> --exclude-database cannot be used with the -d option.
Good catch. The issue was that "vacuumdb -d postgres -D test_db1"
produced "cannot use --exclude-database without --all option", which
is misleading — if the user then adds --all, they hit a second error
("cannot vacuum all databases and a specific one at the same time").
Before (v2):
$ vacuumdb -D test_db1
vacuumdb: error: cannot use --exclude-database without --all option
$ vacuumdb -d postgres -D test_db1
vacuumdb: error: cannot use --exclude-database without --all option
$ vacuumdb -d postgres -D test_db1 --all
vacuumdb: error: cannot vacuum all databases and a specific one at
the same time
After (v3):
$ vacuumdb -D test_db1
vacuumdb: error: cannot use the "exclude-database" option without
the "all" option
$ vacuumdb -d postgres -D test_db1
vacuumdb: error: cannot use the "exclude-database" option with the
"dbname" option
$ vacuumdb -d postgres -D test_db1 --all
vacuumdb: error: cannot vacuum all databases and a specific one at
the same time
v3 adds a separate check that fires first when both -d and
--exclude-database are used together, giving a clear error instead
of bouncing the user between two messages.
Changes in v3:
- Added a check for OBJFILTER_DATABASE_EXCLUDE + OBJFILTER_DATABASE
that fires before the "without all" check, giving a clear error
when both options are specified together.
- Both error messages now use the pg_fatal("%s") format consistent
with other option-conflict errors in vacuumdb.c.
- Updated TAP test to match the new error messages.
--
Mohamed Ali
AWS RDS
Re: [PATCH] vacuumdb: Add --exclude-database option
От:
Ben Mejia <benjamin.arthur.mejia@gmail.com>
Дата:
I think that the behavior of this patch that silently ignores --exlcude-database "non-existent-db" is broken. What if someone has a large database "my-db-name", and they misspell it: $ vacuumdb --all --exclude-database "my-dbname" This will kick off a vacuum including the "my-db-name" they were trying to exclude. I think it would be better to generate an error and not do anything in this case. This also tracks with vacuumdb's existing behavior on --table/--schema which will tell you about a typo.
Re: [PATCH] vacuumdb: Add --exclude-database option
От:
Khoa Nguyen <kdnguyen9.oss@gmail.com>
Дата:
On Wed, Jun 17, 2026 at 7:24 PM Ben Mejia wrote: > > I think that the behavior of this patch that silently ignores --exlcude-database "non-existent-db" is broken. What if someone has a large database "my-db-name", and they misspell it: > > $ vacuumdb --all --exclude-database "my-dbname" > > This will kick off a vacuum including the "my-db-name" they were trying to exclude. > > I think it would be better to generate an error and not do anything in this case. +1 Since exclude-schema validates and stops on error, I think it would make sense to do the same for exclude-database. Current users are used to this behavior so it's best to keep it consistent. > > This also tracks with vacuumdb's existing behavior on --table/--schema which will tell you about a typo.
Re: [PATCH] vacuumdb: Add --exclude-database option
От:
Khoa Nguyen <kdnguyen9.oss@gmail.com>
Дата:
Traditionally, databases are large and hosted in silos serving critical applications. These critical-application requirements are still there but I'm starting to see more databases being hosted on the same cluster for the purpose of lower resource overhead. These are generally AI produced tools/applications/reports running on cron jobs that do need persistent stores. I have not seen the scale of 5,000+ databases as mentioned in Parallelizing startup with many databases but I'm seeing the requirement for co-location increasing. This proposed command option can definitely help when working with multi-database clusters. I think this is a useful addition to vacuumdb and I hope we can get it through. Please let me know if I can be of any assistance. -Khoa On Thu, Jun 18, 2026 at 9:36 AM Khoa Nguyen wrote: > > On Wed, Jun 17, 2026 at 7:24 PM Ben Mejia > wrote: > > > > I think that the behavior of this patch that silently ignores --exlcude-database "non-existent-db" is broken. What if someone has a large database "my-db-name", and they misspell it: > > > > $ vacuumdb --all --exclude-database "my-dbname" > > > > This will kick off a vacuum including the "my-db-name" they were trying to exclude. > > > > I think it would be better to generate an error and not do anything in this case. > +1 > > Since exclude-schema validates and stops on error, I think it would > make sense to do the same for exclude-database. Current users are > used to this behavior so it's best to keep it consistent. > > > > > This also tracks with vacuumdb's existing behavior on --table/--schema which will tell you about a typo.
Re: [PATCH] vacuumdb: Add --exclude-database option
От:
Ben Mejia <benjamin.arthur.mejia@gmail.com>
Дата:
On 10/6/26 11:41 AM, Khoa Nguyen wrote: > Traditionally, databases are large and hosted in silos serving > critical applications. These critical-application requirements are > still there but I'm starting to see more databases being hosted on the > same cluster for the purpose of lower resource overhead. These are > generally AI produced tools/applications/reports running on cron jobs > that do need persistent stores. I have not seen the scale of 5,000+ > databases as mentioned in Parallelizing startup with many databases > but I'm seeing the requirement for co-location increasing. This > proposed command option can definitely help when working with > multi-database clusters. > > I think this is a useful addition to vacuumdb and I hope we can get it > through. Please let me know if I can be of any assistance. > > -Khoa > > On Thu, Jun 18, 2026 at 9:36 AM Khoa Nguyen wrote: >> >> On Wed, Jun 17, 2026 at 7:24 PM Ben Mejia >> wrote: >>> >>> I think that the behavior of this patch that silently ignores --exlcude-database "non-existent-db" is broken. What if someone has a large database "my-db-name", and they misspell it: >>> >>> $ vacuumdb --all --exclude-database "my-dbname" >>> >>> This will kick off a vacuum including the "my-db-name" they were trying to exclude. >>> >>> I think it would be better to generate an error and not do anything in this case. >> +1 >> >> Since exclude-schema validates and stops on error, I think it would >> make sense to do the same for exclude-database. Current users are >> used to this behavior so it's best to keep it consistent. >> >>> >>> This also tracks with vacuumdb's existing behavior on --table/--schema which will tell you about a typo. Mohamed, If you'd like, I can assume authorship of this patch and post it to the current CF. Let me know... -Ben Mejia