Extension architecture help required

Gervase Markham gerv at mozilla.org
Fri Apr 27 09:42:49 UTC 2012


Hi,

In my Sync extension:
http://bzr.mozilla.org/bugzilla/extensions/sync/
I am using the bug_end_of_update hook to do syncing once a bug is
updated. However, in the current implementations of sync clients, I sync
asynchronously, to avoid blocking the main execution. So what happens is
that a job gets added to the job queue which does the sync for that bug,
and some time later the job gets pulled off and run.

One of the job parameters is the bug ID, because the jobqueue system
Stores (using Storable) its parameters, and it doesn't like Storing the
entire updated bug object. So I pass the ID and recreate the object
using new Bugzilla::Bug($id);

This is normally fine, because the job queue comes with a bit of a delay
built in. However, bug_end_of_update runs inside a transaction. If the
job gets pulled off the queue and run before the transaction completes
(which is perhaps more likely if a bug is part of a large batch update,
all of which share a transaction - see process_bug.cgi) then when the
syncing job recreates the bug object, it gets stale data. And the wrong
data gets sent to the remote system.

How can I avoid this? Ideally I want a generic solution, such that the
"something's changed" event isn't even triggered until the database has
been updated. But there's no hook for that, and there isn't an obvious
place to add one. Otherwise, is there some way my code can wait for the
transaction to complete? Problem is, it would need to do so in each
individual syncing job implementation, which is an implementation detail
I'd hope to hide.

Ideas welcome!

Gerv
_______________________________________________
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