#8232 DuplicateKeyError can happen on forum thread ids

v1.10.0
closed
None
General
2018-10-30
2018-09-17
No

I've seen this happen:

DuplicateKeyError: (u'E11000 duplicate key error collection: project-data.forum_thread index: _id_ dup key: { : "168e810d" }'

I believe this is because the Thread class has _id = FieldProperty(str, if_missing=lambda: h.nonce(8)) and the nonce function uses hexadecimal so there are 16^8 = 4.3B possibilities, and with many documents in your system, picking one of 4.3B possibilities might happen to be an existing value. We could increase the size of that to 9 or 10, and/or handle the error better (retry?)

Discussion

  • Kenton Taylor - 2018-09-20
    • status: open --> review
    • assigned_to: Kenton Taylor
     
  • Kenton Taylor - 2018-09-20

    kt/8232

     
  • Dave Brondsema

    Dave Brondsema - 2018-09-20
    • status: review --> closed
    • Reviewer: Dave Brondsema
     
  • Dave Brondsema

    Dave Brondsema - 2018-10-30
    • Milestone: unreleased --> v1.10.0
     

Log in to post a comment.