#8742 closed defect (worksforme)
[PATCH] bugzilla2trac.py - "sqlite3.IntegrityError" in addTicketChange()
Reported by: | 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)
Change History (11)
by , 15 years ago
Attachment: | patch.diff added |
---|
follow-up: 4 comment:1 by , 15 years ago
Owner: | set to |
---|
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 , 15 years ago
Milestone: | → not applicable |
---|
comment:3 by , 15 years ago
Owner: | removed |
---|
comment:4 by , 15 years ago
Component: | general → contrib |
---|
comment:5 by , 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 , 15 years ago
Attachment: | patch-debian_lenny-bugzilla_3.2.4.diff added |
---|
patch for debian lennz, bugzilla 3.2.4
comment:6 by , 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 , 14 years ago
Keywords: | patch added |
---|---|
Summary: | bugzilla2trac.py - "sqlite3.IntegrityError" in addTicketChange() → [PATCH] bugzilla2trac.py - "sqlite3.IntegrityError" in addTicketChange() |
comment:8 by , 13 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
This should actually work now that we have microsecond timestamps. Please reopen if this is still an issue with a recent 0.12.x.
Patch