Bosh clean-up command fails with PG::ForeignKeyViolation error due to foreign key constraint
search cancel

Bosh clean-up command fails with PG::ForeignKeyViolation error due to foreign key constraint

book

Article ID: 387531

calendar_today

Updated On:

Products

Operations Manager

Issue/Introduction

When issuing `bosh clean-up --all` to clean up unused objects on BOSH director, it fails with error as below example. 

...
Task 4334 | 07:02:11 | Deleting releases: routing/0.319.0 (00:00:01)
Task 4334 | 07:02:11 | Error: PG::ForeignKeyViolation: ERROR:  update or delete on table "templates" violates foreign key constraint "instances_templates_template_id_fkey" on table "instances_templates"
DETAIL:  Key (id)=(345) is still referenced from table "instances_templates".
...

Environment

  • Operations Manager all releases

Cause

The problem is caused by unhealthy instances which are managed by the BOSH director. 

Resolution

  1. Run `bosh cck` to find out any unhealthy instances and resolve any issues. 
  2. Rerun `bosh clean-up --all`, it should succeed.