P4DTI issue job000221

TitleRefreshing Perforce jobs fails in Bugzilla integration
Assigned userNick Barnes
DescriptionRefreshing Perforce jobs doesn't work in the Bugzilla integration.
You get the following error:
File "bugzilla.py", line 192, in sqlquote
    raise error, ("sqlquote given non-string %s." % str(value))
P4DTI Bugzilla interface error: sqlquote given non-string None.
AnalysisWhen refreshing Perforce (refresh_perforce.py, now refresh.py), the replicator gets all the issues and then replicates them to Perforce. It does not do this inside the 'changed_entities()/mark_changes_done()' wrapper which it uses for regular replication. The Bugzilla interface (dt_bugzilla.py/bugzilla.py) uses this wrapper to keep track of replication activity (e.g. locking MySQL tables, running processmail scripts, and maintaining a notion of a current replication). For instance, changed_entities() calls new_replication(); mark_changes_done() calls end_replication().
So when refreshing Perforce, bugzilla.replication is None so inserting or updating into any of the p4dti tables will break. Refreshing Perforce inserts rows into the p4dti_bugs table (when creating each bugzilla_bug object), and this is what is breaking.
Ideally we would have a wrapper for replication activity in the defect_tracker interface, independent of the changed_entities()/mark_changes_done() pair (e.g. defect_tracker.start_replication()/defect_tracker.end_replication()). Then replicate_all_dt_to_p4() could call these and we would be fixed.
The problem with this is that the "marker" passed from changed_entities() to mark_changes_done() is related to the set of entities returned by changed_entities(). If we have start_replication() which returns a marker to be passed to end_replication() then this marker will not be related to the entities returned by changed_entities().
Best alternative fix is to ensure that the Bugzilla module (bugzilla.py) always has a notion of "the current (or most recent) replication". This can be achieved by calling bugzilla.new_replication() and bugzilla.end_replication() in dt_bugzilla.init().
How foundcustomer
Observed in0.5.1
Introduced in0.5.0
Test procedure<http://www.ravenbrook.com/project/p4dti/master/test/test_p4dti.py>, section 8.1
Created byGareth Rees
Created on2001-02-20 14:57:50
Last modified byGareth Rees
Last modified on2001-12-10 19:25:13
History2001-02-20 GDR Created.
2001-02-21 NB Added analysis.


Change Effect Date User Description
8896 closed 2001-02-22 10:58:17 Nick Barnes Fix job000221.