Problem:
The database of the smartproxy is much bigger than the foreman/katello main instance.
The worst offenders are the tables core_publishedartifact and core_task, is it safe to clean these tables?
Can i safely install the rpm for foreman on the smartproxy? That rpm includes the foreman-rake tool. Can I use it to clean the old jobs from the smartproxy? I did that on the main instance some months ago.
Expected outcome:
Smartproxy’s database with similar size as foreman/katello.
Foreman and Proxy versions:
- foreman: 3.8
Foreman and Proxy plugin versions:
- foreman_tasks: 8.2.0
- foreman_ansible: 12.07
- foreman_openscap: 7.0.0
- foreman_remote_execution: 11.1.0
- foreman_statistics: 2.1.0
- katello: 4.10.0
Distribution and version:
RockLinux 8.8
Other relevant data:
Some months the foreman/katello database was getting huge.
After the correction of some bugs related to the orphans cleanup, some vacuum operations and deleting old jobs (using foreman-rake…) the database has an acceptable size. Unfortunately the database of the smartproxy we have on another location (which only manages less tha 10 machines - the main instance has several hundred) is huge.
I tried to Reclaim Space from the interface, but it appears to be stuck for several hours at 73%.
This query appears to be the problematic one:
SELECT DISTINCT ON ("core_content"."pulp_type") "core_content"."pulp_id",
"core_content"."pulp_created",
"core_content"."pulp_last_updated",
"core_content"."pulp_type",
"core_content"."upstream_id",
"core_content"."timestamp_of_interest",
"core_content"."pulp_domain_id"
FROM "core_content"
INNER JOIN "core_repositorycontent"
ON ("core_content"."pulp_id" = "core_repositorycontent"."content_id")
WHERE ("core_repositorycontent"."repository_id"
IN ('018c62f018d0741f8a173ebe5f24079b'::uuid,
'018c62bd9d137c52b780c778bc187d0b'::uuid,
'1794145a4d7246ee9c69dd56d2f68328'::uuid,
(...)
I even added some extra space to the partition so a vacuum full operation had enough space available, but it did nothing.
smartproxy:
foreman=# \c pulpcore;
You are now connected to database "pulpcore" as user "postgres".
pulpcore=# select schemaname as table_schema,
relname as table_name,
pg_size_pretty(pg_total_relation_size(relid)) as total_size,
pg_size_pretty(pg_relation_size(relid)) as data_size,
pg_size_pretty(pg_total_relation_size(relid) - pg_relation_size(relid))
as external_size
from pg_catalog.pg_statio_user_tables
order by pg_total_relation_size(relid) desc,
pg_relation_size(relid) desc
limit 10;
table_schema | table_name | total_size | data_size | external_size
--------------+-------------------------------+------------+-----------+---------------
public | core_publishedartifact | 55 GB | 22 GB | 33 GB
public | core_task | 16 GB | 979 MB | 15 GB
public | rpm_package | 2737 MB | 671 MB | 2065 MB
public | core_remoteartifact | 745 MB | 484 MB | 261 MB
public | core_userrole | 712 MB | 160 MB | 552 MB
public | core_repositorycontent | 658 MB | 171 MB | 487 MB
public | guardian_userobjectpermission | 284 MB | 77 MB | 207 MB
public | core_contentartifact | 244 MB | 83 MB | 161 MB
public | core_progressreport | 209 MB | 142 MB | 67 MB
public | rpm_updatecollectionpackage | 207 MB | 165 MB | 42 MB
(10 rows)
foreman/katello:
foreman=# \c pulpcore;
You are now connected to database "pulpcore" as user "postgres".
pulpcore=# select schemaname as table_schema,
relname as table_name,
pg_size_pretty(pg_total_relation_size(relid)) as total_size,
pg_size_pretty(pg_relation_size(relid)) as data_size,
pg_size_pretty(pg_total_relation_size(relid) - pg_relation_size(relid))
as external_size
from pg_catalog.pg_statio_user_tables
order by pg_total_relation_size(relid) desc,
pg_relation_size(relid) desc
limit 10;
table_schema | table_name | total_size | data_size | external_size
--------------+-------------------------------+------------+-----------+---------------
public | core_publishedartifact | 18 GB | 6268 MB | 12 GB
public | core_repositorycontent | 7720 MB | 1731 MB | 5989 MB
public | core_task | 4901 MB | 612 MB | 4289 MB
public | rpm_package | 4412 MB | 1125 MB | 3287 MB
public | rpm_updatecollectionpackage | 1461 MB | 1134 MB | 326 MB
public | rpm_updatereference | 541 MB | 374 MB | 167 MB
public | core_remoteartifact | 491 MB | 303 MB | 188 MB
public | rpm_updaterecord | 457 MB | 285 MB | 172 MB
public | guardian_userobjectpermission | 397 MB | 108 MB | 289 MB
public | core_content | 320 MB | 110 MB | 210 MB
(10 rows)