Project

General

Profile

Bug #21766

Duplicate entries in taxable_taxonomies table

Added by Tomer Brisker almost 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Organizations and Locations
Target version:
Difficulty:
Triaged:
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1494688

Description of problem:

It is possible for duplicate entries to be placed in taxable_taxonomies table.

Example:

id   | taxonomy_id | taxable_id | taxable_type |         created_at         |         updated_at         
-------+-------------+------------+--------------+----------------------------+----------------------------
17766 | 15 | 76 | Subnet | 2017-08-10 09:05:41.651359 | 2017-08-10 09:05:41.651359
17767 | 15 | 76 | Subnet | 2017-08-10 09:05:41.687729 | 2017-08-10 09:05:41.687729

Notice the consecutive ids and virtually identical created_at timestamps

Version-Release number of selected component (if applicable): Satellite 6.2.11

How reproducible: No known reproducer - but seems like the point in time which the row is created is a good starting point. Possible that a unique constraint could be placed around (taxonomy_id, taxable_id).

Steps to Reproduce:
1.
2.
3.

Actual results: Duplicate entries as shown in the example

Expected results:

select taxable_type, taxable_id, taxonomy_id, COUNT() as Duplicates from taxable_taxonomies GROUP BY taxable_type, taxable_id,taxonomy_id HAVING COUNT() > 1;

This query should not ever return results.

Additional info: This manifests via APIs which deal with taxonomies such as Locations

curl -X GET -k -u admin https://localhost/api/v2/subnets/:subnet_id/locations"


Related issues

Blocks Foreman - Refactor #21639: unique constraints should be enforced in the DB as wellNew2017-11-13

Associated revisions

Revision c5787ac1 (diff)
Added by Tomer Brisker almost 3 years ago

Fixes #21766 - Enforce uniquness of TaxableTaxonomy in DB

History

#1 Updated by Tomer Brisker almost 3 years ago

  • Blocks Refactor #21639: unique constraints should be enforced in the DB as well added

#2 Updated by The Foreman Bot almost 3 years ago

  • Assignee set to Tomer Brisker
  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/5028 added

#3 Updated by Anonymous almost 3 years ago

  • % Done changed from 0 to 100
  • Status changed from Ready For Testing to Closed

#4 Updated by Marek Hulán almost 3 years ago

  • Legacy Backlogs Release (now unused) set to 296

Also available in: Atom PDF