[egenix-users] Re: [Zope-DB] Wierd rollback problem in mxODBC DA

M.-A. Lemburg mal at egenix.com
Thu Oct 21 06:48:27 EDT 2004

Charlie Clark wrote:
> Hi Phil,
> I've cc'd this to the egenix-users list as not many people seem to know it 
> exists.

[Note that egenix-users is member posting only due to the amount of
  spam we would receive otherwise]

> If you suspect that mxODBC is somehow responsible then you should try the 
> call externally and then as an ExternalMethod. The mxODBCZopeDA essentially 
> passes most of the work to the mxODBC driver with the intelligence going 
> into managing threads and transactions. Should the problem be traceable to 
> mxODBC we could provide a debugging version of the driver but I suspect 
> this is _not_ the case. It is more likely to be in the transactional 
> machinery so you need to enable Zope's debugging.
> Charlie
> On 2004-10-21 at 10:56:41 [+0200], Philip Kilner <phil at xfr.co.uk> wrote:
>>Hi List,
>>I have a problem which may or may not be mODBC DA related. The target
>>database is MS SQL Server 2000.
>>A script which calls a ZSQL method which inserts records into a table
>>from data in a view was reported to be running without error but having
>>no effect.
>>On testing the ZSQL method in isolation, the results set returned the
>>appropriate number of records, complete with identity field data. On
>>reviewing the table, the records were not there but the counter for the
>>identity field indicated that the numbers in question had been allocated.
>>As far as I can determine, this must be a failed transaction which is
>>being rolled back (But should I see a result dataset in the ZSQL method
>>if this were the case?). However, I see no error indicating the reason
>>for the failure, and when the identical code to that in the ZSQL method
>>was run as a stored procedure, the process ran as intended (e.g. the
>>transaction was not rolled back).
>>How can I figure out if I am right about the roll back, and identify the
>>reason for the difference in behaviour of the same script in the two
>>different locations?

The mxODBC Zope DA's transaction mechanism is controlled by Zope,
so if Zope thinks that it needs to undo or redo the current transaction,
it signals this to the DA which then issues a rollback as necessary.

If you want to have the DA generate debug output, you have
to set the internal variable _debug to 1 or 2. This can only be
done at the Python level by importing the product and adjusting
the variable directly:

from Products.mxODBCZopeDA import ZopeDA
ZopeDA._debug = 2

The DA will then print out lots and lots of information, including
whether it issues a rollback or commit.

>>I do not now have a failing data set - subsequent batches of data were
>>processed as intended, using the ZSQL Method.

Marc-Andre Lemburg

Professional Python Services directly from the Source  (#1, Oct 21 2004)
 >>> Python/Zope Consulting and Support ...        http://www.egenix.com/
 >>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::

More information about the Zope-DB mailing list