#7647 Script to clean up, or code to handle, Dupe Key errors on wiki page_history [ss8446]

v1.2.0
closed
General
2015-08-20
2014-08-29
No

Users get errors like the following from time to time when trying to save a wiki page. I think it may also occur occasionally for tickets. We should be able to clean this up easily, or better yet update the site code to handle the error automatically and continue.

File '/var/local/env-allura/lib/python2.7/site-packages/Ming-0.4.7-py2.7.egg/ming/session.py', line 162 in insert
  bson = self._impl(doc).insert(data, safe=kwargs.get('safe', True))
File '/var/local/env-allura/lib/python2.7/site-packages/TimerMiddleware-0.4.4-py2.7.egg/timermiddleware/__init__.py', line 117 in wrapper
  return self.run_and_log(func, inst, *args, **kwargs)
File '/var/local/env-allura/lib/python2.7/site-packages/TimerMiddleware-0.4.4-py2.7.egg/timermiddleware/__init__.py', line 126 in run_and_log
  return func(*args, **kwargs)
File '/var/local/env-allura/lib/python2.7/site-packages/pymongo-2.4.2-py2.7-linux-x86_64.egg/pymongo/collection.py', line 359 in insert
  continue_on_error, self.__uuid_subtype), safe)
File '/var/local/env-allura/lib/python2.7/site-packages/pymongo-2.4.2-py2.7-linux-x86_64.egg/pymongo/mongo_client.py', line 844 in _send_message
  rv = self.__check_response_to_last_error(response)
File '/var/local/env-allura/lib/python2.7/site-packages/pymongo-2.4.2-py2.7-linux-x86_64.egg/pymongo/mongo_client.py', line 785 in __check_response_to_last_error
  raise DuplicateKeyError(details["err"])
DuplicateKeyError: (u'E11000 duplicate key error index: project-data.page_history.$artifact_class_1_artifact_id_1_version_1
dup key: { : "forgewiki.model.wiki.Page", : ObjectId(\\'53bd2ee190954717fae54832\\'), : 51 }', 'doc:
{\\'import_id\\': None, \\'app_config_id\\': ObjectId(\\'538661d5c4d1041477a0e495\\'), \\'artifact_id\\': ObjectId(\\'53bd2ee190954717fae54832\\'),
    \\'author\\': {\\'username\\': u\\'kenlunde\\', \\'display_name\\': u\\'Dr. Ken Lunde\\', \\'id\\': ObjectId(\\'4cc585dcb9363c527a0000bf\\'),
    \\'logged_ip\\': \\'X.X.X.X\\'}, \\'deleted\\': False, \\'timestamp\\': datetime.datetime(2014, 8, 29, 15, 47, 3, 985000),
    \\'labels\\': [], \\'artifact_class\\': \\'forgewiki.model.wiki.Page\\', \\'acl\\': [], \\'version\\': 51,
    \\'mod_date\\': datetime.datetime(2014, 8, 29, 15, 47, 3, 987628), \\'_id\\': ObjectId(\\'5400a077485acd3627d716fe\\'),
    \\'data\\': {\\'import_id\\': None, \\'app_config_id\\': ObjectId(\\'538661d5c4d1041477a0e495\\'),
        \\'title\\': u\\'Release Notes\\', \\'deleted\\': False,
        \\'text\\': u\\'Test\\\\r\\\\n\\\\r\\\\n# Overview\\\\r\\\\n*Source Han Sans* is a set of OpenType/CFF Pan-CJK f.....

Related

Tickets: #1903

Discussion

  • Dave Brondsema

    Dave Brondsema - 2014-09-08
    • Size: --> 2
     
  • Dave Brondsema

    Dave Brondsema - 2014-09-22
    • Milestone: forge-sep-19 --> forge-oct-3
     
  • Dave Brondsema

    Dave Brondsema - 2014-09-22
    • Milestone: forge-oct-3 --> forge-oct-17
     
  • Igor Bondarenko - 2014-10-07
    • Owner: Anonymous --> Igor Bondarenko
    • Labels: support --> support, 42cc
    • Status: open --> in-progress
     
  • Igor Bondarenko - 2014-10-17
    • status: in-progress --> code-review
     
  • Igor Bondarenko - 2014-10-17

    Closed #669. je/7647

    I didn't manage to reproduce this by hand, but made a test.

    You can test it like this:

    • git checkout HEAD~2 while on the branch
    • cd ForgeWiki
    • nosetests forgewiki.tests.test_models:TestPageSnapshots._test_version_race
    • make sure it fails and raises dup key errors.
    • git checkout je/7647
    • run test again nosetests forgewiki.tests.test_models:TestPageSnapshots.test_version_race (note it's renamed)
    • make sure it passes and doesn't raise anything
     
  • Dave Brondsema

    Dave Brondsema - 2014-10-20
    • Milestone: forge-oct-17 --> forge-oct-31
     
  • Dave Brondsema

    Dave Brondsema - 2014-10-23
    • status: code-review --> closed
    • QA: Dave Brondsema
     
  • Dave Brondsema

    Dave Brondsema - 2014-10-30
    • Labels: support, 42cc, sf-2 --> support, 42cc, sf-current, sf-2
     
  • Dave Brondsema

    Dave Brondsema - 2014-11-03
    • labels: support, 42cc, sf-current, sf-2 --> support, 42cc, sf-2
     
  • Dave Brondsema

    Dave Brondsema - 2015-01-05
    • Milestone: unreleased --> asf_release_1.2.0
     

Log in to post a comment.