Edgewall Software
Modify

Opened 14 years ago

Closed 14 years ago

#9993 closed defect (worksforme)

"Unexpected error" in trac-post-commit-hook while adding more than one ticket/s

Reported by: trac.edgewall@… Owned by:
Priority: normal Milestone:
Component: ticket system Version: 0.11-stable
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

I found a bug in trac-post-commit-hook, when used scripted, a script can call trac-post-commit-hook more than one time per second, on the same ticket, if we do so :

One line 183 :

    ticket.save_changes(self.author, self.msg, self.now, db, cnum+1)

Will fail as self.now is datetime.now(utc) (line 156) with a database error (as i run mysql i got):

Unexpected error while processing ticket ID 98: (1062, "Duplicate entry '98-1295877592-comment' for key 1")

Note that 1062 is just the mysql error number for duplicate entry.

I have two possible and combinable fixes to propose :

  • while catching the duplicate entry exception, just increment the timestamp by one, and retry (more than one time, as i can create more than 2 tickets by seconds :-) )
  • Propose an optional parameter to the script to force the time so the time can be set to the real comment time (as, when i push 10 tickts / seconds, it's from a queue and each have not been written the same second) which will less suposed to conflict (but which can).

Attachments (0)

Change History (1)

comment:1 by Christian Boos, 14 years ago

Resolution: worksforme
Status: newclosed
Version: 0.11-stable

3rd possibility: upgrade to Trac 0.12, which uses microseconds timestamps and will therefore be immune to this problem. Be sure to follow the advices found in TracRepositoryAdmin#trac-post-commit-hook and the rest of that page for a smooth migration.

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.