This document has been created as a reference to HCX Network Extension Duplicate Key error and how to recover that.
For HCX Network Extension (NE) services, attempt to extend an existing extended segment to another site/cloud post modification in the extended segment name using NSX-T manager may led to the Duplicate Key error.
As a result, The old extended segment name will remain visible in the HCX Network Extension UI without any change.
Below logs can be seen in the HCX system:
App-engine logs:
HCX Manager : /common/logs/admin/app.log
2023-02-08 10:49:40.430 UTC [NSXService_SvcThread-1364, Ent: HybridityAdmin, , TxId: ########-####-####-####-########9f1b] ERROR c.v.v.h.a.postgresdb.PostgresAdapter- Error Updating query {"collection":"NsxtLogicalSwitch","keys":["id","nsxUuid"],"rows":[{"switch_type":"DEFAULT","transport_zone_id":"########-####-####-####-########44ab", <snip> ,"resource_type":"LogicalSwitch","id":"########-####-####-####-########c81a","display_name":"NdvS_DMZ_PRE_EPRES_VIRT_GDC_65632","tags":[{"scope":"2081","tag":"VLAN"},{"scope":"policyPath","tag":"\/infra\/segments\/NdvS_GDC_PRE_OK_over2081"},{"scope":"subnet-cidr","tag":"172.25.172.128\/25"}],"_create_user":"nsx_policy","_create_time":1585815935162,"_last_modified_user":"nsx_policy","_last_modified_time":1673353347274,"_system_owned":false,"_protection":"REQUIRE_OVERRIDE","_revision":9,"_schema":"\/v1\/schema\/ <snip>
PostgresDB log:
HCX Manager : /common/logs/postgres/postgresql<date>.log
2023-02-08 08:39:57.394 GMT [8551] STATEMENT: INSERT INTO "NsxtSegment"(val) VALUES (to_jsonb($1::jsonb)) 2023-02-08 08:39:57.414 GMT [8551] ERROR: duplicate key value violates unique constraint "NsxtSegment_path_1" 2023-02-08 08:39:57.414 GMT [8551] DETAIL: Key ((val ->> 'path'::text))=(/infra/segments/NdvS_GDC_PRE_OK_over2081) already exists.