Project

General

Profile

Actions

Bug #5225

closed

Deleting a puppet-class: Mysql2::Error: Cannot delete or update a parent row: a foreign key constraint fails

Added by Daniel Schutterop over 10 years ago. Updated over 10 years ago.

Status:
Duplicate
Priority:
Normal
Assignee:
-
Category:
Database
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

It seems I can't delete any puppet classes from Foreman after upgrading from 1.2 to 1.4.2:

Foreman Message

Warning!
Mysql2::Error: Cannot delete or update a parent row: a foreign key constraint fails (`foreman`.`environment_classes`, CONSTRAINT `environment_classes_puppetclass_id_fk` FOREIGN KEY (`puppetclass_id`) REFERENCES `puppetclasses` (`id`)): DELETE FROM `puppetclasses` WHERE `puppetclasses`.`id` = 150

Foreman Trace info:

ActiveRecord::StatementInvalid
Mysql2::Error: Cannot delete or update a parent row: a foreign key constraint fails (`foreman`.`environment_classes`, CONSTRAINT `environment_classes_puppetclass_id_fk` FOREIGN KEY (`puppetclass_id`) REFERENCES `puppetclasses` (`id`)): DELETE FROM `puppetclasses` WHERE `puppetclasses`.`id` = 150
app/controllers/puppetclasses_controller.rb:42:in `destroy'
app/models/concerns/foreman/thread_session.rb:33:in `clear_thread'
lib/middleware/catch_json_parse_errors.rb:9:in `call' 

Production log:

Started DELETE "/puppetclasses/disclaimer" for 10.38.5.22 at 2014-04-17 13:19:32 +0200
Processing by PuppetclassesController#destroy as HTML
  Parameters: {"authenticity_token"=>"<deleted>", "id"=>"disclaimer"}
Operation FAILED: Mysql2::Error: Cannot delete or update a parent row: a foreign key constraint fails (`foreman`.`environment_classes`, CONSTRAINT `environment_classes_puppetclass_id_fk` FOREIGN KEY (`puppetclass_id`) REFERENCES `puppetclasses` (`id`)): DELETE FROM `puppetclasses` WHERE `puppetclasses`.`id` = 32
  Rendered common/500.html.erb within layouts/application (3.9ms)
  Rendered layouts/base.html.erb (1.4ms)
Completed 500 Internal Server Error in 33ms (Views: 6.6ms | ActiveRecord: 9.3ms)

Mysql foreman->puppetclasses

mysql> select * from puppetclasses where id=32;
+----+------------+---------------------+---------------------+
| id | name       | created_at          | updated_at          |
+----+------------+---------------------+---------------------+
| 32 | disclaimer | 2013-11-25 10:57:22 | 2013-11-25 10:57:22 |
+----+------------+---------------------+---------------------+
1 row in set (0.00 sec)

Mysql foreman->environment_classes
mysql> select * from environment_classes where puppetclass_id=32;
+----------------+----------------+-----+---------------+
| puppetclass_id | environment_id | id  | lookup_key_id |
+----------------+----------------+-----+---------------+
|             32 |              9 | 425 |          NULL |
|             32 |             11 | 581 |          NULL |
+----------------+----------------+-----+---------------+
2 rows in set (0.00 sec)

Local gems

ansi (1.4.3)
awesome_print (1.0.2)
builder (3.2.2)
clamp (0.6.2)
daemon_controller (1.1.4)
excon (0.31.0)
fastercsv (1.5.4)
fastthread (1.0.7)
fog (1.20.0)
foreman_api (0.1.11)
formatador (0.2.4)
hammer_cli (0.0.18)
hammer_cli_foreman (0.0.18)
hashie (2.0.5)
highline (1.6.20)
json (1.4.6)
kafo (0.3.17)
little-plugger (1.1.3)
logging (1.8.1)
mime-types (1.25.1, 1.16)
multi_json (1.8.4, 1.8.2)
net-scp (1.1.2)
net-ssh (2.8.0)
nokogiri (1.5.11)
oauth (0.4.7)
passenger (4.0.5)
plist (3.1.0)
powerbar (1.0.11)
rack (1.1.0)
rack-test (0.5.4)
rake (0.8.7)
rdoc (3.12)
rest-client (1.6.1)
rkerberos (0.1.2)
rubyipmi (0.7.0)
sinatra (1.0)
table_print (1.1.5)

Mysql Version

mysql  Ver 14.14 Distrib 5.1.66, for redhat-linux-gnu (x86_64) using readline 5.1

Platform

CentOS 6.4

Any thoughts on what I'm doing wrong?

Thanks,

Daniel


Related issues 1 (0 open1 closed)

Is duplicate of Foreman - Bug #4379: Foreign key constraint error on deleting a classResolved02/18/2014Actions
Actions #1

Updated by Marek Hulán over 10 years ago

  • Category set to Database

Thanks for nice report, seems like the same issue we have for PG DB.

Actions #2

Updated by Marek Hulán over 10 years ago

  • Is duplicate of Bug #4379: Foreign key constraint error on deleting a class added
Actions #3

Updated by Dominic Cleal over 10 years ago

  • Status changed from New to Duplicate
Actions

Also available in: Atom PDF