ARTIFACTORY: How to fix “missing chunk number 0 for toast value 150941 in pg_toast_108462” error in the Postgres database

ARTIFACTORY: How to fix “missing chunk number 0 for toast value 150941 in pg_toast_108462” error in the Postgres database

AuthorFullName__c
Suhas CS
articleNumber
000006181
ft:sourceType
Salesforce
FirstPublishedDate
2024-09-05T10:42:39Z
lastModifiedDate
2024-09-04
VersionNumber
1

We will be getting the below error while performing the DB dump creation or exporting the Access configuration on Artifactory using the REST API. Below are the error for the reference.

Access configuration export error -

org.jfrog.access.server.exception.BackupException: Unable to export access server
Caused by: org.jfrog.access.server.exception.AccessStorageException: Could not export platform configurations
Caused by: org.postgresql.util.PSQLException: ERROR: missing chunk number 0 for toast value 150941 in pg_toast_108462

DB dump creation error -
pg_dump: Dumping the contents of table "access_platform_config" failed: PQgetResult() failed.
 pg_dump: Error message from server: ERROR: missing chunk number 0 for toast value 150941 in pg_toast_108462
 pg_dump: The command was: COPY public.access_platform_config (config_key, revision, created, modified, configuration, is_secret) TO stdout;
 pg_dumpall: pg_dump failed on database "artifactory", exiting

We will need to track the corrupted DB entry in the database Access table considering the current case where the access_platform_config table is throwing the error. Also, the error can be confirmed by using the below-mentioned DB command.
SELECT * FROM access_platform_config;

ERROR: missing chunk number 0 for toast value 150941 in pg_toast_108462

The error related to the corrupted DB entry in the access_platform_config table can be tracked and deleted by using the below commands to fix the reported issue.
To get the total count of entries in access_platform_config table - 
SELECT count(*) FROM access_platform_config;

Update the count considering the output above command - 
for ((i=0; i<6; i++ )); do psql -U "Username" "Database_Name" -c "SELECT * FROM access_platform_config LIMIT 1 offset $i" >/dev/null || echo $i; done

Update the offset value based on the output from the above command which will give a corrupted db entry - 
select config_key from access_platform_config limit 1 offset 2;

Delete the corrupted DB entry and perform the vacuum on the table -
delete from access_platform_config where config_key = 'corrupted_db_entry';
VACUUM FULL access_platform_config;