Skip to content

Run Maintenance on the selected partition rather than its parent table. #10895 - #10900

Merged
dpage merged 1 commit into
pgadmin-org:masterfrom
dpage:fix/issue-10895-maintenance-partition
Nov 30, 2026
Merged

dpage merged 1 commit into
pgadmin-org:masterfrom
dpage:fix/issue-10895-maintenance-partition

Conversation

@dpage

@dpage dpage commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Maintenance on a partition sent the parent table's name, and the schema node the partition is listed under, so it ran e.g. VACUUM (VERBOSE) public.parent; for both public.child and other.child2. It now uses the partition and its own schema (schema_name from its node data). That also fixes an index or constraint on a partition in a different schema from its parent, where the partition is filed under table in the tree hierarchy.
  • The logic moves from setExtraParameters into maintenance_utils.js so it can be unit tested.
  • ONLY is shown for partitions again. Add support for the ONLY option to VACUUM and ANALYZE in the Maintenance dialog. #9062 #9059 #10838 hid it only because the command named the parent; with the partition now targeted, ONLY is meaningful for a partition that is itself partitioned, and on a leaf partition it is the same harmless no-op as on an ordinary table with no children, which already shows it. The docs say "table or partition" accordingly.

Test plan

  • Reproduced in the running app (PostgreSQL 18) before the fix: the job POST carried schema: public, table: parent for both partitions. After the fix: public.child, other.child2, and other / child2_id_idx for an index on child2; ONLY shown.
  • VACUUM (VERBOSE) ONLY other.child2 and ANALYZE ONLY public.child run cleanly on PostgreSQL 18.
  • Jest: new regression/javascript/maintenance/maintenance_utils_spec.js (4 of its 7 cases fail against the old logic) and the updated ONLY cases in maintenance.ui.spec.js: 17 passed. ESLint clean on the changed files.

Closes #10895

Summary by CodeRabbit

  • New Features
    • The VACUUM and ANALYZE dialogs now offer the ONLY option when a table or partition is selected.
    • Maintenance actions now use the selected partition’s name and schema when applicable.
  • Documentation
    • Updated the maintenance guide to clarify that ONLY is available for selected tables and partitions from version 18 onward.

pgadmin-org#10895

The Maintenance dialog filled in the table name from the parent table when a
partition was selected, and the schema from the schema node the partition is
listed under, so VACUUM, ANALYZE, REINDEX and CLUSTER processed the parent
(and, without ONLY, the whole hierarchy). It now targets the partition in its
own schema, which also fixes an index or constraint on a partition that lives
in a different schema from its parent.

With partitions targeted correctly, the PostgreSQL 18 ONLY switch is shown for
them again; it is meaningful for a partition that is itself partitioned.

Closes pgadmin-org#10895
@dpage dpage self-assigned this Nov 30, 2026
@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Maintenance now builds job parameters from the selected partition when applicable, including its schema. The ONLY option is available for table and partition selections for VACUUM and ANALYZE. Documentation and regression tests cover these changes.

Changes

Partition Maintenance

Layer / File(s) Summary
Build parameters for the selected target
web/pgadmin/tools/maintenance/static/js/maintenance_utils.js, web/pgadmin/tools/maintenance/static/js/maintenance.js, web/regression/javascript/maintenance/maintenance_utils_spec.js
A new helper builds maintenance job data from the tree hierarchy. It prefers a selected partition and uses its schema when available. setExtraParameters calls the helper. Tests cover partitions, sub-partitions, indexes, materialized views, tables, and schemas.
Enable ONLY for partition selections
web/pgadmin/tools/maintenance/static/js/maintenance.ui.js, web/regression/javascript/schema_ui_files/maintenance.ui.spec.js, docs/en_US/maintenance_dialog.rst
For VACUUM and ANALYZE, the ONLY option now applies to selected tables and partitions. Tests and documentation reflect the updated behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

  • pgadmin-org/pgadmin4#10838: Adds the ONLY switch for VACUUM and ANALYZE and defines its visibility behavior in the maintenance dialog.
Merge Risk: Minimal · up to f366c

Maintenance jobs now target the selected partition and its own schema, and the ONLY option is offered for partitions. The supporting server payloads carry the partition schema, and the tests cover the new behavior. No merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title states the main change: maintenance jobs (VACUUM, ANALYZE, and related actions) now run on the selected partition instead of its parent table. The raw summary and objectives confirm this is …
Linked Issues check Passed [#10895] The PR moves the target logic into getMaintenanceExtraData in maintenance_utils.js, and setExtraParameters in maintenance.js now returns its result. For a selected partition, `treeInf…
Out of Scope Changes check Passed The changes fall into three groups: (1) the targeting fix in maintenance_utils.js and maintenance.js (#10895); (2) Jest coverage in maintenance_utils_spec.js and maintenance.ui.spec.js for tha…
Full details: Title check

Explanation

The title states the main change: maintenance jobs (VACUUM, ANALYZE, and related actions) now run on the selected partition instead of its parent table. The raw summary and objectives confirm this is the core change, along with the schema fix and the ONLY option restoration for partitions. The title is specific and matches the linked issue #10895. It does not cover the ONLY option change, but that is a secondary aspect.

Full details: Linked Issues check

Explanation

[#10895] The PR moves the target logic into getMaintenanceExtraData in maintenance_utils.js, and setExtraParameters in maintenance.js now returns its result. For a selected partition, treeInfo.partition is used before treeInfo.table, so the job receives the partition name, not the parent name. For a partition filed under table (for example, an index on child2), the same expression selects the partition. When the target has _type == 'partition' and a schema_name, that schema replaces the tree schema, so other.child2 and its index use schema other. The maintenance_utils_spec.js Jest cases cover tables, partitions, sub-partitions, indexes on partitions, materialized views, and schemas. I did not open the spec file itself; this relies on the PR summary and the source diff. The issue's coding requirements are met by the source logic at the reviewed head.

Full details: Out of Scope Changes check

Explanation

The changes fall into three groups: (1) the targeting fix in maintenance_utils.js and maintenance.js (#10895); (2) Jest coverage in maintenance_utils_spec.js and maintenance.ui.spec.js for that fix; (3) the ONLY change in maintenance.ui.js (isApplicableForOnly now allows partitions) and its documentation update in maintenance_dialog.rst. Group 3 is not a stated coding requirement of #10895. The issue treats the hidden ONLY option as background, and the PR ties its restoration to the new targeting: once the partition is the target, ONLY applies to a partitioned partition and is a no-op on a leaf. That link is concrete, so I do not treat it as unrelated. The reviewer may still want to confirm that the ONLY restoration is accepted as part of this issue.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 0abbc67 and f366c28.

Files selected for processing: 6

  • docs/en_US/maintenance_dialog.rst
  • web/pgadmin/tools/maintenance/static/js/maintenance.js
  • web/pgadmin/tools/maintenance/static/js/maintenance.ui.js
  • web/pgadmin/tools/maintenance/static/js/maintenance_utils.js
  • web/regression/javascript/maintenance/maintenance_utils_spec.js
  • web/regression/javascript/schema_ui_files/maintenance.ui.spec.js

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 1 remain after this review.

@dpage
dpage merged commit 8226ce1 into pgadmin-org:master Nov 30, 2026
18 checks passed
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.

Maintenance on a partition processes its parent table instead

1 participant