Project

Profile

Help

Issue #1577

migration 0022_distributor_collection_trim fails with DuplicateKeyError

Added by mhrivnak almost 5 years ago. Updated almost 2 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
High
Category:
-
Sprint/Milestone:
-
Start date:
Due date:
Estimated time:
Severity:
1. Low
Version:
Master
Platform Release:
2.8.0
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Pulp 2
Sprint:
Quarter:

Description

I did these steps:

  • install pulp 2.7.1
  • sync the "zoo" repo
  • mongodump --db pulp_database
  • use mongorestore on a fresh "master" 2.8.0
  • run pulp-manage-db

In theory the dump and restore shouldn't have an impact here, but I included that detail just in case.

I suspect this is related to there being a unique index including "repo_id" and "id". When you rename the "id" field, perhaps that's setting the value in the index to null (we see a hint of that in the error message below), which invites a uniqueness violation if there is more than one distributor on a repository.

Here's where mongorestore create the index, for reference:

Creating index: { unique: true, key: { repo_id: -1, id: -1 }, name: "repo_id_-1_id_-1", ns: "pulp_database.repo_distributors", background: true }

and this is the error from pulp-manage-db:

Attempting to connect to db:27017
Write concern for Mongo connection: {'w': 'majority'}
Loading content types.
Loading type descriptors [python.json]
Parsing type descriptors
Validating type descriptor syntactic integrity
Validating type descriptor semantic integrity
Updating the database with types [python_package]
Found the following type definitions that were not present in the update collection [puppet_module, erratum, srpm, package_group, package_category, iso, package_environment, drpm, distribution, rpm, yum_repo_metadata_file, docker_image]
Content types loaded.
Ensuring the admin role and user are in place.
Admin role and user are in place.
Beginning database migrations.
Applying pulp.server.db.migrations version 19
Migration to pulp.server.db.migrations version 19 complete.
Applying pulp.server.db.migrations version 20
Migration to pulp.server.db.migrations version 20 complete.
Applying pulp.server.db.migrations version 21
Migration to pulp.server.db.migrations version 21 complete.
Applying pulp.server.db.migrations version 22
Applying migration pulp.server.db.migrations.0022_distributor_collection_trim failed.

Halting migrations due to a migration failure.
E11000 duplicate key error index: pulp_database.repo_distributors.$repo_id_-1_id_-1  dup key: { : "zoo", : null }
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/pulp/server/db/manage.py", line 183, in main
    return _auto_manage_db(options)
  File "/usr/lib/python2.7/site-packages/pulp/server/db/manage.py", line 246, in _auto_manage_db
    migrate_database(options)
  File "/usr/lib/python2.7/site-packages/pulp/server/db/manage.py", line 124, in migrate_database
    update_current_version=not options.test)
  File "/usr/lib/python2.7/site-packages/pulp/server/db/migrate/models.py", line 186, in apply_migration
    migration.migrate()
  File "/usr/lib/python2.7/site-packages/pulp/server/db/migrations/0022_distributor_collection_trim.py", line 18, in migrate
    collection.update({}, {"$rename": {"id": "distributor_id"}}, multi=True)
  File "/usr/lib64/python2.7/site-packages/pymongo/collection.py", line 552, in update
    _check_write_command_response(results)
  File "/usr/lib64/python2.7/site-packages/pymongo/helpers.py", line 198, in _check_write_command_response
    raise DuplicateKeyError(error.get("errmsg"), 11000, error)
DuplicateKeyError: E11000 duplicate key error index: pulp_database.repo_distributors.$repo_id_-1_id_-1  dup key: { : "zoo", : null }

Related issues

Blocks Pulp - Task #1416: Write a docker script to containerize pulp 2.8 and the validation script (task 1415)CLOSED - CURRENTRELEASE

<a title="Actions" class="icon-only icon-actions js-contextmenu" href="#">Actions</a>

History

#1 Updated by mhrivnak almost 5 years ago

  • Blocks Task #1416: Write a docker script to containerize pulp 2.8 and the validation script (task 1415) added

#2 Updated by amacdona@redhat.com almost 5 years ago

  • Status changed from NEW to POST
  • Assignee set to amacdona@redhat.com

#3 Updated by amacdona@redhat.com almost 5 years ago

  • Status changed from POST to MODIFIED

#4 Updated by jortel@redhat.com almost 5 years ago

  • Triaged changed from No to Yes

#5 Updated by dkliban@redhat.com almost 5 years ago

  • Status changed from MODIFIED to 5

#6 Updated by dkliban@redhat.com almost 5 years ago

  • Status changed from 5 to CLOSED - CURRENTRELEASE

#7 Updated by bmbouter almost 2 years ago

  • Tags Pulp 2 added

Please register to edit this issue

Also available in: Atom PDF