Updating/Patching vCenter Server from 8.0U1 to 8.0U2 or later releases fails with "ERROR: P0001,Failed to add primary key pk_vpx_schema_hash on table vc.vpx_schema_hash"
search cancel

Updating/Patching vCenter Server from 8.0U1 to 8.0U2 or later releases fails with "ERROR: P0001,Failed to add primary key pk_vpx_schema_hash on table vc.vpx_schema_hash"

book

Article ID: 404001

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

  • Patching vCenter Server from 8.0U1 to 8.0U2 or later releases  fails with the error: vcdb.ndu.expand.generic.error
  • Upon checking var/log/vmware/applmgmt/PatchRunner.log we may notice similar entries:
    psql.bin:/storage/updatemgr/software-updateg60ytkup/stage/scripts/patches/payload/components-script/vcdb/ndu/vcdb_expand.sql:1432: ERROR:  P0001,Failed to add primary key pk_vpx_schema_hash on table vc.vpx_schema_hash - sqlstate: 23505, sqlerrm: could not create unique index "pk_vpx_schema_hash"
    
    CONTEXT:  PL/pgSQL function vcdb_ndu_cln_processor(text[]) line 20 at RAISE
    YYYY-MM-DDTHH:MM:SSZ vcdb:Patch ERROR vmware_b2b.patching.executor.hook_executor Patch hook 'vcdb:Patch' failed.
    
    Traceback (most recent call last):
      File "/storage/updatemgr/software-updateg60ytkup/stage/scripts/patches/py/vmware_b2b/patching/executor/hook_executor.py", line 74, in executeHook
        executionResult = systemExtension(args)
      File "/storage/updatemgr/software-updateg60ytkup/stage/scripts/patches/libs/sdk/extensions.py", line 106, in __call__
        result = self.extension(*args)
      File "/storage/updatemgr/software-updateg60ytkup/stage/scripts/patches/libs/sdk/extensions.py", line 123, in _func
        return func(*args)
      File "/storage/updatemgr/software-updateg60ytkup/stage/scripts/patches/payload/components-script/vcdb/__init__.py", line 212, in patch
        _run_expand()
      File "/storage/updatemgr/software-updateg60ytkup/stage/scripts/patches/payload/components-script/vcdb/__init__.py", line 137, in _run_expand
        raise UserError(cause=cause)
    patch_errors.UserError: Failed to extend the database state.
    2025-07-10T19:49:32.410Z ERROR vmware_b2b.patching.phases.patcher Patch hook Patch got ComponentWrapperError.
    Traceback (most recent call last):
      File "/storage/updatemgr/software-updateg60ytkup/stage/scripts/patches/py/vmware_b2b/patching/phases/patcher.py", line 208, in patch
        _patchComponents(ctx, userData, statusAggregator.reportingQueue)
      File "/storage/updatemgr/software-updateg60ytkup/stage/scripts/patches/py/vmware_b2b/patching/phases/patcher.py", line 90, in _patchComponents
        executeComponentHook(Hook.Patch, ctx, c, userData, reportingQueue)
      File "/storage/updatemgr/software-updateg60ytkup/stage/scripts/patches/py/vmware_b2b/patching/executor/execution_facade.py", line 97, in executeComponentHook
        result = executeHook(c.patchScript, hook, args,
      File "/storage/updatemgr/software-updateg60ytkup/stage/scripts/patches/py/vmware_b2b/patching/executor/execution_facade.py", line 53, in executeHook
        result = executor.executeHook(scriptFile, hook, args, reportQueue, reportIdentifier)
      File "/storage/updatemgr/software-updateg60ytkup/stage/scripts/patches/py/vmware_b2b/patching/executor/hook_executor_process.py", line 119, in executeHook
        raise ex
    patch_errors.ComponentError
    YYYY-MM-DDTHH:MM:SSZ WARNING root stopping status aggregation...
    YYYY-MM-DDTHH:MM:SSZ ERROR __main__ Patch vCSA failed
  • While checking var/log/vmware/applmgmt/upgrade_hook_PatchHook we may notice similar entries:
    {
        "progress": ##,
        "progress_message": {
            "detail": [
                {
                    "id": "vcdb.ndu.expand.generic.error",
                    "translatable": "Failed to extend the database state.",
                    "localized": "Failed to extend the database state."
                }
            ],
            "componentKey": "vcdb:Patch",
            "problemId": null,
            "resolution": null
        },
        "status": "error",
        "info": [],
        "warning": [],
        "question": null,
        "error": {
            "detail": [
                {
                    "id": "vcdb.ndu.expand.generic.error",
                    "translatable": "Failed to extend the database state.",
                    "localized": "Failed to extend the database state."
                }
            ],
            "componentKey": "vcdb:Patch",
            "problemId": null,
            "resolution": null
        },
        "start_time": "YYYY-MM-DDTHH:MM:SSZ",
        "end_time": "YYYY-MM-DDTHH:MM:SSZ"
    }

Environment

VMware vCenter Server

Cause

The primary key creation failed because the table vc.vpx_schema_hash contains duplicate rows with identical values. SQL tables with primary keys must ensure that each row has a unique value. During the upgrade process, an additional row was unintentionally inserted into the table, causing the conflict and preventing the creation of the primary key.

Resolution

  1. Revert to the snapshot taken before updating the vCenter.

  2. Open an SSH session to the vCenter VM and execute the following commands in the order specified below:

  3. Stop vpxd and content library service

    service-control --stop vmware-vpxd && service-control --stop vmware-content-library

    Note, The vCenter Server UI will be inaccessible until the services are started.

  4. View existing entries in the vpx_ext_upgrade table

    /opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres -c "\x" -c "select * from vpx_schema_hash;"
  5. Delete existing entries from the vpx_ext_upgrade table

    /opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres -c "delete from vpx_schema_hash;"
  6. Verify that the vpx_ext_upgrade table is empty

    /opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres -c "\x" -c "select * from vpx_schema_hash;"
  7. Insert a new value into the vpx_ext_upgrade table

    /opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres -c "insert into vpx_ext_upgrade (status) values (0);"
  8. Verify the table has the correct value (only one entry)

    /opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres -c "\x" -c "select * from vpx_schema_hash;"
  9. Restart vpxd and content library service
    service-control --start vmware-vpxd && service-control --start vmware-content-library
  10. Retry the vCenter update workflow after taking a new snapshot of the vCenter Server instance.

Note: Before making any changes to a vCenter Server database, ensure to create an offline snapshot of the entire vCenter Server instance if the vCenter is part of an Enhanced Linked Mode (ELM) setup. For a standalone vCenter Server Instance, ensure that a snapshot is taken without memory.

Note: As the required edits involve changes to the vCenter Server's database, which may be potentially destructive, it is advisable to thread with caution and if needed reach out to Broadcom Support referring to this KB for assistance.