Problem with Sybase, Rollbacks and prepare_cached

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with Sybase, Rollbacks and prepare_cached

Tina Müller
Hi,

I am working with Sybase Open Client libs and the latest
DBIx::Class.
I stumbled over this weird thing:
Doing two transactions with rollbacks (because of a duplicate)
results in:

Setting of CS_OPT_CHAINXACTS failed.
...
Unexpected transaction depth of 1 on freshly connected handle

Here are my classes, the create table and the output:
http://paste.scsys.co.uk/469383

I have been debugging a lot.
The CS_OPT_CHAINXACTS error message comes from DBD::Sybase dbdimp.c.

Turning DBI_TRACE on additionally gives me:
Message String: ct_send(): user api layer: external error: This routine cannot be called because another command structure has results pending.

It turns out that turning off prepare_cached helps. Then I get
the expected "Attempt to insert duplicate key" in both transactions,
and transaction_depth is set to 0.
So it seems that the $sth is not really "finished", when rollback is
called after the first transaction.
This is probably because of the INSERT command. To retrieve the
insert id the command is actually an INSERT plus SELECT MAX(id)...
(The error does not happen with an UPDATE, for example)

I've been debugging in DBIC::Storage::DBI::_dbh_execute mainly.

If I do two transactions/rollbacks with plain DBI and prepare_cached,
I get this error at the end of the script:
DBD::Sybase::st DESTROY failed: OpenClient message: LAYER = (1) ORIGIN = (1) SEVERITY = (1) NUMBER = (159)
Server server, database
Message String: ct_cmd_drop(): user api layer: external error: This routine can be called only if the command structure is idle.

This also confirms that there might be a statement handle which
is not finished.

Although this points to DBD::Sybase I thought I ask here, since
it looks like there is a lot of magic in Storage::DBI::* and the
author(s) maybe know about the problem.

I'm glad for any hints. The current workarounds could be to
turn of prepare_cached, or to disconnect dbh after a rollback
happened.

Thanks,
tina

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Sybase, Rollbacks and prepare_cached

Tina Müller
On Sat, 14 Mar 2015, Peter Rabbitson wrote:

> On 03/13/2015 06:23 PM, Tina Müller wrote:
>> Hi,
>>
>> I am working with Sybase Open Client libs and the latest
>> DBIx::Class.
>
> Before we go further with "remote debugging" - is this something I can
> potentially recreate on a local install of Sybase? What sort of free/dev
> versions are there available? If nothing like this exists - would it be
> possible to get me a personal temporary accunt on your RDBMS so I can
> determine its behavior?
For the record: We are discussing this (possibility of
local debugging) further on IRC.

As far as I was told one should be able to get a free Sybase developer
version which includes the Sybase Open Client libraries.
Installing it independently from the Sybase server seems
to be more complicated.

We are working on a fresh test instance that can reproduce
the error.

tina
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...