Locking bugs temporarily?

David Marshall dmarshal at yahoo-inc.com
Fri Feb 24 16:47:05 UTC 2012


I don't like hard locks such as what you get with SELECT ... FOR UPDATE
because they're better for database integrity than for mutual exclusion.

Fortunately, you can use MySQL as a source of mutual exclusion with the
GET_LOCK function:

http://dev.mysql.com/doc/refman/5.1/en/miscellaneous-functions.html#function
_get-lock

SELECT GET_LOCK("bug:12345", 10) [or whatever]

Of course, that's an advisory lock only! It's up to you to identify exactly
which transactions should respect the lock.

PostgreSQL implements advisory locks somewhat differently:

http://www.postgresql.org/docs/9.1/static/explicit-locking.html#ADVISORY-LOC
KS

A truly enterprising chap could add subroutines Bugzilla::Object::lock,
Bugzilla:Object::is_locked, and Bugzilla::Object::release_lock that take
advantage of subroutines in Bugzilla::DB.

I'm guessing that the overhead in fiddling with advisory locks is pretty
low, albeit non-zero. I haven't though about it enough to say whether it's
worth it for objects to deal with them by default.

At Yahoo!, in addition to bug mid-airs, we also implement our own product
mid-airs. With 4832 products (as of this morning), we have "product
administrators" who can modify products. Some products have dozens of
administrators, who can and do occasionally try to modify the same thing at
the same time.

On 2/24/12 6:30 AM, "Gervase Markham" <gerv at mozilla.org> wrote:

> I have an extension which integrates Bugzilla with another system. At
> the moment, it's possible for me to get a Bug object and, while I am
> working out how to change it as part of the sync, for someone else to
> update the bug. My changes then overwrite theirs. Obviously, there's a
> fairly small time window, but occurrences of this have been noted.
> 
> I can't really implement conflict resolution logic - that needs a human.
> So I'd really like to lock the bug when I get a copy, make my update
> e.g. 2 seconds later, unlock it, for their change to then try and be
> committed and for _them_ (the human) to get a mid-air that they can
> resolve however they like.
> 
> Is it possible to temporarily lock a bug? Either within Bugzilla or
> using a direct database command on a table row? Would that screw things
> up? Is there a better way of solving this?
> 
> We are using MySQL and, at the moment, Bugzilla 3.6.
> 
> Thanks,
> 
> Gerv
> _______________________________________________
> dev-apps-bugzilla mailing list
> dev-apps-bugzilla at lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-apps-bugzilla
> -
> To view or change your list settings, click here:
> <http://bugzilla.org/cgi-bin/mj_wwwusr?user=dmarshal@yahoo-inc.com>

_______________________________________________
dev-apps-bugzilla mailing list
dev-apps-bugzilla at lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-apps-bugzilla



More information about the developers mailing list