Opened 15 years ago

Last modified 13 years ago

#5402 closed enhancement

add support for detecting mid-air collisions — at Version 3

Reported by: Steffen Pingel Owned by: osimons
Priority: normal Component: XmlRpcPlugin
Severity: normal Keywords:
Cc: Thijs Triemstra, Steffen Pingel Trac Release: 0.11

Description (last modified by osimons)

If the same field of a ticket is updated concurrently by two users the later update overrides the previous change without notice. It would be helpful if Trac supported versioning of tickets and would reject an update if the provided data did not match the version currently in the repository. An example of that is Bugzilla's has a notion of mid-air collision which require updating first and re-submitting in case of a conflict.

The original request filed against Mylyn is tracked here:

253932: submitting changes also sends unchanged fields possibly resetting them to old values https://bugs.eclipse.org/bugs/show_bug.cgi?id=253932

Change History (4)

comment:1 Changed 15 years ago by osimons

Description: modified (diff)

This implies adding a version field to the returned ticket attributes, and then expecting the same marker to be included in the attributes returned for updating. Should be an easy fix.

2 things come to mind:

  • 'version' is already taken by the ticket 'version' field, so I need some other naming. It would need to be something like _version or _ver. I kind of like _ver because it is sufficiently different.
  • We'll likely need to support updates without the marker for a while. I'll update the docs to strongly recommend against not including it, and then remove old-style update along with some other deprecated changes when releasing a 1.1 version or something.

See also #2794 for similar request for wiki pages.

comment:2 Changed 15 years ago by Steffen Pingel

Description: modified (diff)

Does Trac atually have a notion of a version for tickets? If not, we could also consider using the modification timestamp, i.e. the client would send it back and only if it matches the timestamp in the repository would the update succeed.

comment:3 Changed 15 years ago by osimons

Description: modified (diff)

I had timestamp in mind for version - alternatively 'version' as a distinct count of timestamps in ticket_change table (more or less what is used for comment-numbers). Anyway, Trac itself uses the timestamp to detect collision so just using that makes the most sense. It is also returned with any ticket.get() and update() call so it easily accessible.

I've made a patch, and again like for 'action' it tries to do so without changing the API. To support update collision, add a time_changed timestamp to attributes when updating. Not using time_changed is deprecated in the patch, so in some future version any update that includes attributes will require those two keys. When working on update(), I also took the time to make a full set of tests for all various incarnations of updating (all passing).

Attaching patch. Review and feedback welcome.

Changed 15 years ago by osimons

Ticket update collision detection.

Note: See TracTickets for help on using tickets.