ERROR: duplicate key value violates unique constraint "version_thing_id_key" x

Bug #398119 reported by Sam Wilson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Open Library
Won't Fix
Critical
Anand Chitipothu

Bug Description

This happened when I tried to save an edit to http://openlibrary.org/b/OL7390832M/Truth?m=edit

I think it might have something to do with the table of contents? I had to insert a new line in the middle, so moved an existing entry down one; perhaps having all three fields the same as an existing (albeit old) row isn't permitted. Or something. I've no idea.

Revision history for this message
Edward Betts (edwardbetts) wrote :

I get the same error.

Changed in openlibrary:
assignee: nobody → Anand Chitipothu (anandology)
importance: Undecided → Critical
Revision history for this message
George (george-archive) wrote :

Status update, please? Critical?

Revision history for this message
Edward Betts (edwardbetts) wrote :

version table contains revision 7.
data table contains revision 7.
thing table had latest_revision set to 6.

I ran: update thing set latest_revision=7 where id=10067087;

I think this fixed it.

Changed in openlibrary:
status: New → Confirmed
status: Confirmed → Fix Released
Revision history for this message
Anand Chitipothu (anandology) wrote :

There might be other cases. I've spent some time trying to reproduce this, but couldn't. However, it is an open issue. Changing the status to "confirmed" from "fix released".

Changed in openlibrary:
status: Fix Released → Confirmed
Changed in openlibrary:
importance: Critical → High
Revision history for this message
Edward Betts (edwardbetts) wrote :
Download full text (4.4 KiB)

This just happened to me again, here is what I'm trying to pass to ol.save_many():

[{'authors': [<ref: u'/a/OL70757A'>],
  'by_statement': u'Alberto B. Bianchi ; pro\u0301logo de Agusti\u0301n Gordillo.',
  'created': datetime.datetime(2008, 4, 1, 3, 28, 50, 625462),
  'first_sentence': <text: u'"No caben dudas de que la regulaci\xf3n econ\xf3mica tiene una influencia decisiva en el derecho administrativo."'>,
  'isbn_10': ['950569153X', '9505691521'],
  'key': '/b/OL4013036M',
  'languages': [<ref: u'/l/spa'>],
  'last_modified': datetime.datetime(2009, 8, 30, 2, 18, 28, 158847),
  'lc_classifications': ['KHA3739 .B53 2001'],
  'lccn': ['2001378620'],
  'notes': <text: u'Includes bibliographical references and index.'>,
  'number_of_pages': 415,
  'pagination': 'v. <1 > ;',
  'publish_country': 'ag ',
  'publish_date': '2001',
  'publish_places': ['Buenos Aires, Argentina'],
  'publishers': [u'Editorial \xc1baco de Rodolfo Depalma'],
  'series': [u'Fundaci\xf3n de Derecho Constitucional Jos\xe9 Manuel de Estrada'],
  'subject_place': ['Argentina', 'Argentina.'],
  'subjects': ['Trade regulation -- Argentina.',
               'Argentina -- Economic policy.',
               'Regulatory commissions'],
  'subtitle': u'Desarrollo hist\xf3rico. R\xe9gimen jur\xeddico de los entes reguladores de la Argentina',
  'table_of_contents': [{'class': 'part',
                         'label': '1.',
                         'pagenum': '25',
                         'title': u'Desarrollo hist\xf3rico de la regulaci\xf3n econ\xf3mica',
                         'type': <ref: u'/type/toc_item'>},
                        {'class': 'section',
                         'label': 'I.',
                         'pagenum': '25',
                         'title': u'Primer per\xedodo 1870-1930',
                         'type': <ref: u'/type/toc_item'>},
                        {'label': 'II.',
                         'pagenum': '81',
                         'title': u'Segundo per\xedodo 1930-1970',
                         'type': <ref: u'/type/toc_item'>},
                        {'label': 'III.',
                         'pagenum': '143',
                         'title': u'Tercer per\xedodo. Desde 1970 a la fecha',
                         'type': <ref: u'/type/toc_item'>},
                        {'label': '2.',
                         'pagenum': '201',
                         'title': 'Los entes reguladores n la Argentina',
                         'type': <ref: u'/type/toc_item'>},
                        {'label': 'IV.',
                         'pagenum': '201',
                         'title': u'La noci\xf3n de ente regulador y el problema de la coherencia interna en su r\xe9gimen jur\xeddico',
                         'type': <ref: u'/type/toc_item'>},
                        {'label': 'V.',
                         'pagenum': '267',
                         'title': 'Competencia de los entes reguladores',
                         'type': <ref: u'/type/toc_item'>},
                        {'label': 'A)',
                         'pagenum': '267',
                         'title': 'Competencias generales',
                         'type': <ref: u'/type/...

Read more...

Changed in openlibrary:
importance: High → Critical
Revision history for this message
Edward Betts (edwardbetts) wrote :

Happened again:

Traceback (most recent call last):
  File "find_import_works.py", line 52, in <module>
    to_update = update_works(akey, works, do_updates=True)
  File "/1/edward/src/openlibrary/openlibrary/catalog/works/find_works.py", line 644, in update_works
    updated = new_work(akey, w, do_updates, fh_log)
  File "/1/edward/src/openlibrary/openlibrary/catalog/works/find_works.py", line 472, in new_work
    print >> fh_log, ol.save_many(update, "add editions to new work")
  File "/1/edward/src/openlibrary/openlibrary/api.py", line 125, in save_many
    return self._call_write('save_many', query, comment, action)
  File "/1/edward/src/openlibrary/openlibrary/api.py", line 121, in _call_write
    response = self._request('/api/' + name, method="POST", data=simplejson.dumps(query), headers=headers)
  File "/1/edward/src/openlibrary/openlibrary/api.py", line 48, in _request
    raise OLError(e)
OLError: Bad Request: duplicate key value violates unique constraint "version_thing_id_key"

I was trying to save this:

[{'authors': [<ref: u'/a/OL818321A'>],
  'by_statement': 'Hasan Hasani.',
  'created': datetime.datetime(2008, 4, 1, 3, 28, 50, 625462),
  'description': <text: u'das'>,
  'first_sentence': <text: u'sdasd'>,
  'genres': ['Dictionaries.'],
  'id': 5135390,
  'key': '/b/OL3633930M',
  'languages': [<ref: u'/l/alb'>],
  'last_modified': datetime.datetime(2009, 7, 5, 20, 54, 49, 625713),
  'latest_revision': 62,
  'lc_classifications': ['CS2377 .H38 2001'],
  'lccn': ['2002432668'],
  'notes': <text: u'xzzc'>,
  'number_of_pages': 222,
  'pagination': '222 p. ;',
  'publish_date': '2001',
  'publish_places': [u'Prishtine\u0308'],
  'publishers': [u'Shte\u0308pia Botuese Faik Konica'],
  'revision': 62,
  'subjects': ['Names, Personal -- Albanian -- Dictionaries.',
               'Children -- Albania.'],
  'table_of_contents': [{'class': 'subsection',
                         'type': <ref: u'/type/toc_item'>}],
  'title': u'5043 emra shqip pe\u0308r fe\u0308mije\u0308',
  'title_prefix': 'aa',
  'type': <ref: u'/type/edition'>,
  'works': [{'key': '/works/OL15112965W'}]}]

Revision history for this message
George (george-archive) wrote :

Bump

Changed in openlibrary:
milestone: none → general-bucket
Changed in openlibrary:
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.