Fixing stale content libraries in vCenter Appliance

February 3, 2018 – 3:11 pm

Last year we had to rebuild our vCenter (I commented about that in a previous post) using a backup/restore procedure provided by VMware. After the restore, the Update Manager was broken (it’s now fixed) and the Content Libraries were also lost. I didn’t have time to fix it until today. I opened a case with VMware and was provided with the procedure to manually clear out the stale entries for the database.

Symptom:
Unable to delete the stale entry of the content library from the web client. The issue is seen upon restoring the VCDB database post re-deploy. The ‘dcli’ commands are also failing to remove the content library since the same is unable to list the stale entry.

Resolution:

  • Snapshot the vCenter appliance
  • SSH to the VCSA appliance, and enter the shell.
  • Open the Postgres console:
/opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres

Display the Content Library tables content

VCDB=# select id,name from cl_library;

id | name
 ————————————–+——-
8bc3326e-3a0b-49e6-9be0-acb18b91d4b2 | Test
3b4280d3-b878-4428-85d0-867cb8252e66 | Stale

VCDB=# select * from cl_library_storage;

library_id | storage_id
————————————–+————————————–
8bc3326e-3a0b-49e6-9be0-acb18b91d4b2 | ff3f7160-0731-4d01-9cc0-a2cce03ab3ce
3b4280d3-b878-4428-85d0-867cb8252e66 | 1325cd29-0b3e-4be4-8445-625da0dce452
(2 rows)

VCDB=# select * from cl_storage;

id | storageuri | type
————————————–+————————————————————-+———–
ff3f7160-0731-4d01-9cc0-a2cce03ab3ce | Datastore:datastore-11:f271f3f1-a924-4519-a3f5-e9a75d962888 | Datastore
1325cd29-0b3e-4be4-8445-625da0dce452 | Datastore:datastore-11:f271f3f1-a924-4519-a3f5-e9a75d962888 | Datastore
(2 rows)

VCDB=# select id,name from vpx_datastore where id=11;

id | name
—-+——
11 | DS1
(1 row)

Note: As per the snippets above, we see the id for the library is “3b4280d3-b878-4428-85d0-867cb8252e66”.

The storage id for the same library is “1325cd29-0b3e-4be4-8445-625da0dce452”.

When we check the location, we see that the library is saved in the datastore with id “11” (Datastore:datastore-11:f271f3f1-a924-4519-a3f5-e9a75d962888)

We can get the datastore name from the datastore table, which is “DS1” here.

To remove stale entry follow below order.

VCDB=# delete from cl_library_storage where library_id=’3b4280d3-b878-4428-85d0-867cb8252e66′;
VCDB=# delete from cl_storage where id=’1325cd29-0b3e-4be4-8445-625da0dce452′;
VCDB=# delete from cl_library where id=’3b4280d3-b878-4428-85d0-867cb8252e66′;

The output for each of the above command would return “DELETE 1”,Once deleted, we can log in to the web client.

Note: Don’t forget the “;” at the end of each line. If your prompt is VCDB-#, that means it’s waiting for an end-of-line character (the “;”).

 

Post a Comment