EDR: Post EDR 7.8.0 Upgrade the Cbupgrade Fails with Postgres Duplicate Key
search cancel

EDR: Post EDR 7.8.0 Upgrade the Cbupgrade Fails with Postgres Duplicate Key

book

Article ID: 287662

calendar_today

Updated On:

Products

Carbon Black EDR (formerly Cb Response)

Issue/Introduction

The 'cbupgrade' tool fails with error:
Upgrading core model DB schema...
Traceback (most recent call last):
...
psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "cb_settings_pkey"
DETAIL:  Key (key)=(BanningApprovedlistVersion) already exists.
...
conn.execute("UPDATE cb-settings SET key = 'BanningApprovedlistVersion' WHERE key = 'BanningWhitelistVersion';")

 

Environment

  • EDR Server: 7.8.0

Cause

The cbupgrade is attempting to change 'BanningWhitelistVersion' to 'BanningApprovedlistVersion' but the value already exists.  The cause may have been due to a previously failed upgrades to 7.8.0.

Resolution

1.  Confirm the Postgres database has a backup according the the Cluster Management Guide.
2.  Check the entries in the cb_settings table, confirm both 'BanningWhitelistVersion' and 'BanningApprovedlistVersio'n are present.
3.  Due to the many indexes in the Postgres database it is not usually a good idea to modify the database directly;  It is best to use API calls.  Since there is not an API call to remove duplicate keys, the entry required the 'BanningWhitelistVersion' row to be manually removed.
# psql -p 5002 cb
# select * from cb_settings where key='BanningWhitelistVersion';
(Result: 1 row)
# select * from cb_settings where key='BanningApprovedlistVersion';
(Result: 1 row)
# delete from cb_settings where key='BanningWhitelistVersion';
(Result: DELETE 1)
# \q