Edgewall Software
Modify

Opened 15 years ago

Closed 13 years ago

Last modified 12 years ago

#8742 closed defect (worksforme)

[PATCH] bugzilla2trac.py - "sqlite3.IntegrityError" in addTicketChange()

Reported by: drm@… Owned by:
Priority: normal Milestone:
Component: contrib Version: 0.10.5
Severity: minor Keywords: bugzilla2trac, patch
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Exception raised: "sqlite3.IntegrityError: columns ticket, time, field are not unique"

The sqlite db layout seems to prohibit the changes stored in Bugzilla to happen at the same time in the same field. Bugzilla's db doesn't seem to work this way, since all changes in bugzilla are atomic and can follow each other up by one user's action, resulting in multiple changes in one field at the same time.

What I did to fix it was to add one second to the timestamp if the integrity exception occurred. I 've added a diff for this. It might be neater to implement a while loop though, in case there are even more than 2 changes at the same time (I'm not sure this happens at all).

Versions used are: trac 0.10.5 Bugzilla 2.20 Python 2.5 MySQL 5.0.51a (debian)

I didn't test it on other versions, but I probably will soon, since this was just a test run in a virtual machine.

Attachments (2)

patch.diff (1.5 KB ) - added by drm@… 15 years ago.
Patch
patch-debian_lenny-bugzilla_3.2.4.diff (325 bytes ) - added by manuel@… 15 years ago.
patch for debian lennz, bugzilla 3.2.4

Download all attachments as: .zip

Change History (11)

by drm@…, 15 years ago

Attachment: patch.diff added

Patch

comment:1 by drm@…, 15 years ago

Owner: set to Jeroen Ruigrok van der Werven

I ran it on another system today with trac 0.11.1, and for some reason the pysqlite2 module was used in stead of sqlite3. Same patch applies, but I changed the relevant lines:

import sqlite3
import pysqlite2

and

except (sqlite3.IntegrityError, pysqlite2.dbapi2.IntegrityError):

With this patch, it works for 2200, so assigning to jruigrok as stated in bugzilla2trac.py. I'm not sure if some logic is needed to figure out which of the modules is used, and maybe just import the exception so the except block can read

except (IntegrityError): 

HTH :)

comment:2 by Christian Boos, 15 years ago

Milestone: not applicable

comment:3 by Jeroen Ruigrok van der Werven, 15 years ago

Owner: Jeroen Ruigrok van der Werven removed

in reply to:  1 comment:4 by Christian Boos, 15 years ago

Component: generalcontrib

Replying to drm@…:

… assigning to jruigrok as stated in bugzilla2trac.py.

Oops, this is no longer true, fixed in r9282.

comment:5 by Carsten Klein <carsten.klein@…>, 15 years ago

Please note that on high traffic sites the above presented patch will still cause submission of a comment or rather change to an existing ticket to fail.

Perhaps it would be best to also include system nano time with the ticket change?

The best solution however, AFAIK would be to assign a unique id to each potential ticket change and also to remove the constraint of uniqueness on the change and making it a constraint on just the unique id, for example a uuid.

by manuel@…, 15 years ago

patch for debian lennz, bugzilla 3.2.4

comment:6 by manuel@…, 15 years ago

While trying to do the import on Debian Lenny, with Bugzilla 3.2.4, I ran into two small issues:

  • a collision between duplicate components. I suppose that is due to components with the same name in different bugzilla products
  • an issue with the version resolution, or perhaps with the version at which the 'fieldid' field got renamed to 'id'

I guess this is not a very clean solution (there should perhaps be some dynamical renaming of the duplicate components, rather than replacement), but it may help others that are in the same situation than me.

comment:7 by Thijs Triemstra, 14 years ago

Keywords: patch added
Summary: bugzilla2trac.py - "sqlite3.IntegrityError" in addTicketChange()[PATCH] bugzilla2trac.py - "sqlite3.IntegrityError" in addTicketChange()

comment:8 by Remy Blank, 13 years ago

Resolution: worksforme
Status: newclosed

This should actually work now that we have microsecond timestamps. Please reopen if this is still an issue with a recent 0.12.x.

comment:9 by Christian Boos, 12 years ago

Milestone: not applicable

(clearing report:35)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from (none) to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.