MGMT-23553: Automate events table bloat cleanup#10140
MGMT-23553: Automate events table bloat cleanup#10140bluesort wants to merge 1 commit intoopenshift:masterfrom
Conversation
|
@bluesort: This pull request references MGMT-23553 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
Skipping CI for Draft Pull Request. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds a DB migration to tune autovacuum settings for the Changes
Sequence Diagram(s)sequenceDiagram
participant Cron as "K8s CronJob"
participant Job as "CronJob -> Job"
participant Pod as "Reindex Pod"
participant DB as "PostgreSQL"
Cron->>Job: schedule triggers Job
Job->>Pod: create Pod (env from Secret, image, resources)
Pod->>DB: psql connection check (PGHOST/PGUSER/PGPASSWORD)
Pod->>DB: SELECT per-index sizes for public.events (before)
Pod->>DB: REINDEX TABLE CONCURRENTLY public.events
Pod->>DB: SELECT per-index sizes for public.events (after)
Pod->>Pod: compute size delta and log results
Pod->>Job: exit with success/failure
Job->>Cron: Job completes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 8 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (8 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bluesort The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@bluesort: This pull request references MGMT-23553 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@bluesort: This pull request references MGMT-23553 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
deploy/postgres/postgres-reindex.cronjob.yaml.j2 (1)
25-26: Pin the PostgreSQL image to an immutable digest for reproducible scheduled runs.Using a floating tag for this cronjob can cause behavior drift between runs if the image upstream is updated.
Proposed fix
- image: registry.redhat.io/rhel9/postgresql-14 + image: registry.redhat.io/rhel9/postgresql-14@sha256:<approved-digest>🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@deploy/postgres/postgres-reindex.cronjob.yaml.j2` around lines 25 - 26, The cronjob currently uses a floating image tag in the image field (image: registry.redhat.io/rhel9/postgresql-14); replace that with an immutable digest reference (image: registry.redhat.io/rhel9/postgresql-14@sha256:<CALCULATED_DIGEST>) so scheduled runs are reproducible; obtain the correct sha256 digest for the exact image you want (e.g., via skopeo/podman/docker inspect or registry API) and update the template's image value accordingly, ensuring imagePullPolicy remains appropriate for your registry.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@deploy/postgres/postgres-reindex.cronjob.yaml.j2`:
- Around line 60-61: The PGSSLMODE environment variable is hardcoded to
"require"; change it to use a Jinja2 template variable so environments can
override the SSL mode. Replace the fixed value for the PGSSLMODE env entry with
a templated variable (e.g., pg_ssl_mode or postgres_ssl_mode) that defaults to
"require" using Jinja2's default filter, and ensure any deployment
values/helm/README references are updated to document the new template variable
so callers can set modes like "disable" or "verify-full".
- Around line 81-88: The monitoring SELECTs against pg_stat_user_indexes should
be schema-qualified by joining pg_class and pg_namespace rather than filtering a
non-existent schemaname column; update the queries that reference
pg_stat_user_indexes (the SELECTs that filter on relname = 'events') to JOIN
pg_class c ON c.oid = s.indextrelid and JOIN pg_namespace n ON n.oid =
c.relnamespace and then filter WHERE n.nspname = 'public' AND s.relname =
'events' (replace s with the table alias used in the diff); also make the
REINDEX command explicit by qualifying the target as public.events so it
operates on the intended table.
---
Nitpick comments:
In `@deploy/postgres/postgres-reindex.cronjob.yaml.j2`:
- Around line 25-26: The cronjob currently uses a floating image tag in the
image field (image: registry.redhat.io/rhel9/postgresql-14); replace that with
an immutable digest reference (image:
registry.redhat.io/rhel9/postgresql-14@sha256:<CALCULATED_DIGEST>) so scheduled
runs are reproducible; obtain the correct sha256 digest for the exact image you
want (e.g., via skopeo/podman/docker inspect or registry API) and update the
template's image value accordingly, ensuring imagePullPolicy remains appropriate
for your registry.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 7fb2ef7e-e500-461d-8e35-a9edd5d280ae
📒 Files selected for processing (1)
deploy/postgres/postgres-reindex.cronjob.yaml.j2
|
@bluesort: This pull request references MGMT-23553 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@bluesort: This pull request references MGMT-23553 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@bluesort: This pull request references MGMT-23553 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@bluesort: This pull request references MGMT-23553 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@bluesort: This pull request references MGMT-23553 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@bluesort: This pull request references MGMT-23553 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
/test ? |
|
/test all |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #10140 +/- ##
==========================================
+ Coverage 44.13% 44.33% +0.19%
==========================================
Files 415 416 +1
Lines 72319 72783 +464
==========================================
+ Hits 31918 32268 +350
- Misses 37512 37596 +84
- Partials 2889 2919 +30
🚀 New features to boost your workflow:
|
|
/override ci/prow/edge-e2e-metal-assisted-5-0 |
|
@bluesort: Overrode contexts on behalf of bluesort: ci/prow/edge-e2e-metal-assisted-5-0 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/test edge-e2e-ai-operator-ztp |
|
/test edge-e2e-metal-assisted-5-0 |
|
@bluesort: Overrode contexts on behalf of bluesort: ci/prow/edge-e2e-metal-assisted-5-0 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/override ci/prow/edge-e2e-metal-assisted-5-0 |
|
@bluesort: Overrode contexts on behalf of bluesort: ci/prow/edge-e2e-metal-assisted-5-0 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
@bluesort: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Problem
The events table is high-churn with frequent inserts and deletes, resulting in lingering tombstones and index bloat and impacting query performance.
Solution
Configure aggressive autovacuum settings and add a reindex cronjob to periodically reclaim index bloat.
List all the issues related to this PR
What environments does this code impact?
How was this code tested?
Checklist
docs, README, etc)Reviewers Checklist
Summary by CodeRabbit