Postgresql database is growing and disk space utilization of /var/lib/pgsql is increasing in Red Hat Satellite 6

Solution Verified - Updated

Environment

  • Red Hat® Satellite 6.9 and above

Issue

  • The candlepin and/or foreman database has grown huge.
  • The usage of /var/lib/pgsql filesystem is in GB's now and growing further day by day.
  • Performance of the Red Hat Satellite server has been degraded.

Resolution


CAUTION: It's recommended to take a Satellite Backup or VMware snapshot of the Red Hat Satellite server before proceeding any further with the cleanup process.


STEP 1: Perform Diagnosis:

  • At first, go through the Diagnostic Steps section of this article to identify the tables containing a huge amount of data inside the foreman or candlepin database.

    • Execute the postgres-size-report.sh on the Red Hat Satellite server 6.9 and below.
    • Execute the postgres-size-report-with-pulpcore.sh on the Red Hat Satellite server 6.10 and above.
    • Identify the table consuming a good amount of space (in GB).
    • Note down the table name which requires cleanup.

STEP 2: Investigate and cleanup Candlepin database:

  • It's usually the cp_event table that grows inside the candlepin database.
  • If the postgres-size-report-with-pulpcore.sh script have displayed abnormal size for the cp_event table, then follow the steps mentioned in the solution article 3083651 to further investigate and cleanup.

STEP 3: Investigate and cleanup foreman database:

STEP 4: Investigate and cleanup pulpcore database ( applicable for Satellite 6.11+ ):

  • Cleanup

    • Any unused CV and CCV versions
    • Any CV or CCV that may no longer be needed at all
    • Any repositories that may no longer be needed anymore
  • Clean up the orphaned data. Refer to the following article 6685201 for the same.

  • Reduce the amount of rpm changelog entries stored in the database by following the approach mentioned in the article 6977656 for Red Hat Satellite 6.11.

  • Perform the vacuumdb operation on pulpcore database by referring to the next section of this article.

     

STEP 5: Perform vacuuming on the individual databases:

  • As It's been mentioned earlier, It might only be required to clean up one or two tables based on the initial diagnosis and once the cleanup has been performed, re-execute the postgres-size-report-with-pulpcore.sh script and identify if the sizes of the concerned tables got reduced or not.

  • The deletion of records from different tables can still keep the disk space reserved in the database. To finish the cleanup process, it is also advised to perform vacuuming of the database as per the solution article How to perform vacuuming on the individual Red Hat Satellite 6 databases?

In case of any questions or further concerns, please reach out to This content is not included.Red Hat Technical Support.

For more KB articles/solutions related to Red Hat Satellite 6.x PostgreSQL-related Issues, please refer to the Consolidated Troubleshooting Article for Red Hat Satellite 6.x PostgreSQL-related Issues

Root Cause

  • There are multiple sceanrios present which could be the reason behind the growth of postgres database.

    • Old and\or Orphaned data is still residing in individual database tables and requires manual cleanup.
    • The cronjobs for clearing old sessions and reports data are not running properly.
    • Too many old tasks and audit reports present in the Database.
    • Hosts were removed from satellite but the related host facts are still present in the satellite database.

Diagnostic Steps

1

Download the script postgres-size-report-with-pulpcore.sh attached in this article, copy inside satellite server, execute the same

# chomd +x postgres-size-report-with-pulpcore.sh
# ./postgres-size-report-with-pulpcore.sh
 - This script shows the following details.

    1. The total size of both the candlepin and foreman database.
    2. The individual size of all the tables inside the candlepin database.
3. The individual size of all the tables inside the foreman database.
4. The usage of the filesystem related to postgresql.
5. Count of total data and data older than days for some of the concerned tables from the foreman database which gets easily filled up and causes performance issues.
  • From the output of the script, identify the large tables consuming data in GB's or having an unexpected amount of records in some of the tables causing the table to grow huge. An example of huge table size will look something like below.

                  table_name               |  total  |  index  |   toast    |  table
    ---------------------------------------+---------+---------+------------+---------
     sessions                              | 39 GB   | 21 GB   | 8192 bytes | 18 GB
     audits                                | 17 GB   | 1041 MB | 14 GB      | 1832 MB
    

 

  • Investigate if the cronjobs present inside /etc/cron.d/foreman are getting executed properly or not.
SBR
Product(s)
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.