Subject: | syb_chained_txn causes errors during "connect" and "disconnect" |
-- Test program
#! /usr/bin/perl
use DBI;
use strict;
use warnings;
# point the DSQUERY environment variable to a server
my $d = DBI->connect('dbi:Sybase:', '<user>, '<password>',
{AutoCommit => 0, RaiseError => 1, syb_chained_txn => 1});
$d->disconnect;
print "all done\n";
--
-- Expected output
all done
--
-- Actual output
DBD::Sybase::db STORE failed: Server message number=3902 severity=16 state=1 line=2 server=SQL2008TEST text=The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION. at /home/nmisch/sw/cpan/lib/perl5/i486-linux-gnu-thread-multi/DBI.pm line 726.
DBD::Sybase::db STORE failed: Server message number=3902 severity=16 state=1 line=2 server=SQL2008TEST text=The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION. at /home/nmisch/sw/cpan/lib/perl5/i486-linux-gnu-thread-multi/DBI.pm line 726.
DBD::Sybase::db disconnect failed: Server message number=3903 severity=16 state=1 line=2 server=SQL2008TEST text=The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION. at minimal-sybase.pl line 9.
DBD::Sybase::db disconnect failed: Server message number=3903 severity=16 state=1 line=2 server=SQL2008TEST text=The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION. at minimal-sybase.pl line 9.
--
-- Software Versions
Perl/OS: v5.8.8 built for i486-linux-gnu-thread-multi
DBI 1.631
DBD::Sybase 1.15
FreeTDS 0.91.103
SQL Server 2008
-- freetds.conf snippet
[global]
tds version = 7.0
port = 1433
[TEST]
host = SQL2008TEST
--
I have attached the output with DBI_TRACE=5 set in the environment. During
"connect", setting syb_chained_txn to any value prompts a COMMIT TRAN. Under
DBI 1.630 or DBI 1.631, you receive the first two errors reported above. (Note
that these do not raise exceptions, despite RaiseError=>1.) Earlier DBI
versions such as DBI 1.628 do not print the error, but the error is accessible
in $d->errstr. The "disconnect" both prints an error and raises an exception;
that behavior has no known DBI version dependency, but it does not happen under
syb_chained_txn=>0.
Perhaps a fix should take the form of tracking whether the server is in a
transaction and skipping some of these transaction control commands when it is
not? Alternately, ignore errors from internally-generated transaction control
commands that are expected to fail sometimes?
Thanks,
nm
Subject: | trace.txt |
DBI 1.631-ithread default trace level set to 0x0/5 (pid 5333 pi 8152008) at DBI.pm line 288 via minimal-sybase.pl line 3
Note: perl is running without the recommended perl -w option
-> DBI->connect(dbi:Sybase:, nmtest, ****, HASH(0x8152c28))
-> DBI->install_driver(Sybase) for linux perl=5.008008 pid=5333 ruid=1000 euid=1000
syb_init() -> DBD::Sybase 1.15 initialized
OpenClient version: freetds v0.91.103 (threadsafe, default tds version=7.0)
install_driver: DBD::Sybase version 1.15 loaded from /home/nmisch/sw/cpan/lib/perl5/i486-linux-gnu-thread-multi/DBD/Sybase.pm
New 'DBI::dr' (for DBD::Sybase::dr, parent='', id=undef)
dbih_setup_handle(DBI::dr=HASH(0x820880c)=>DBI::dr=HASH(0x82089a4), DBD::Sybase::dr, 0, Null!)
dbih_make_com(Null!, 0, DBD::Sybase::dr, 84, 0) thr#8152008
dbih_setup_attrib(DBI::dr=HASH(0x82089a4), Err, Null!) SCALAR(0x824d3fc) (already defined)
dbih_setup_attrib(DBI::dr=HASH(0x82089a4), State, Null!) SCALAR(0x824d3e4) (already defined)
dbih_setup_attrib(DBI::dr=HASH(0x82089a4), Errstr, Null!) SCALAR(0x824d414) (already defined)
dbih_setup_attrib(DBI::dr=HASH(0x82089a4), TraceLevel, Null!) 0 (already defined)
dbih_setup_attrib(DBI::dr=HASH(0x82089a4), FetchHashKeyName, Null!) 'NAME' (already defined)
<- install_driver= DBI::dr=HASH(0x820880c)
-> connect for DBD::Sybase::dr (DBI::dr=HASH(0x820880c)~0x82089a4 '' 'nmtest' **** HASH(0x8215054)) thr#8152008
New 'DBI::db' (for DBD::Sybase::db, parent=DBI::dr=HASH(0x82089a4), id=undef)
dbih_setup_handle(DBI::db=HASH(0x82ec174)=>DBI::db=HASH(0x82ec0f0), DBD::Sybase::db, 824d5dc, Null!)
dbih_make_com(DBI::dr=HASH(0x82089a4), 817e858, DBD::Sybase::db, 3228, 0) thr#8152008
dbih_setup_attrib(DBI::db=HASH(0x82ec0f0), Err, DBI::dr=HASH(0x82089a4)) SCALAR(0x824d768) (already defined)
dbih_setup_attrib(DBI::db=HASH(0x82ec0f0), State, DBI::dr=HASH(0x82089a4)) SCALAR(0x824d7c8) (already defined)
dbih_setup_attrib(DBI::db=HASH(0x82ec0f0), Errstr, DBI::dr=HASH(0x82089a4)) SCALAR(0x824d798) (already defined)
dbih_setup_attrib(DBI::db=HASH(0x82ec0f0), TraceLevel, DBI::dr=HASH(0x82089a4)) 0 (already defined)
dbih_setup_attrib(DBI::db=HASH(0x82ec0f0), FetchHashKeyName, DBI::dr=HASH(0x82089a4)) 'NAME' (already defined)
dbih_setup_attrib(DBI::db=HASH(0x82ec0f0), HandleSetErr, DBI::dr=HASH(0x82089a4)) undef (not defined)
dbih_setup_attrib(DBI::db=HASH(0x82ec0f0), HandleError, DBI::dr=HASH(0x82089a4)) undef (not defined)
dbih_setup_attrib(DBI::db=HASH(0x82ec0f0), ReadOnly, DBI::dr=HASH(0x82089a4)) undef (not defined)
dbih_setup_attrib(DBI::db=HASH(0x82ec0f0), Profile, DBI::dr=HASH(0x82089a4)) undef (not defined)
syb_db_login() -> using global CS_LOCALE data
servermsg_cb -> number=5701 severity=0 state=2 line=1 server=SQL2008TEST text=Changed database context to 'master'.
servermsg_cb -> number=5703 severity=0 state=1 line=1 server=SQL2008TEST text=Changed language setting to us_english.
syb_db_login() -> checking for chained transactions
syb_db_login() -> ct_option is supported
syb_db_login() -> chained transactions are supported
syb_alloc_cmd() -> CS_COMMAND 82f0fb0 for CS_CONNECTION 82f0e70
get_server_version() -> ct_command(select @@version)
get_server_version() -> ct_results(4040)
get_server_version() -> version = Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (X64)
Jul 9 2008 14:17:44
Copyright (c) 1988-2008 Microsoft Corporation
Standard Edition (64-bit) on Windows NT 5.2 <X64> (Build 3790: Service Pack 2)
get_server_version() -> version = Unknown
get_server_version() -> ct_results(4046)
<- connect= DBI::db=HASH(0x82ec174) at /home/nmisch/sw/cpan/lib/perl5/i486-linux-gnu-thread-multi/DBI.pm line 671
-> STORE for DBD::Sybase::db (DBI::db=HASH(0x82ec0f0)~INNER 'RaiseError' 1) thr#8152008
STORE DBI::db=HASH(0x82ec0f0) 'RaiseError' => 1
<- STORE= 1 at /home/nmisch/sw/cpan/lib/perl5/i486-linux-gnu-thread-multi/DBI.pm line 723
-> STORE for DBD::Sybase::db (DBI::db=HASH(0x82ec0f0)~INNER 'PrintError' 1) thr#8152008
STORE DBI::db=HASH(0x82ec0f0) 'PrintError' => 1
<- STORE= 1 at /home/nmisch/sw/cpan/lib/perl5/i486-linux-gnu-thread-multi/DBI.pm line 723
-> STORE for DBD::Sybase::db (DBI::db=HASH(0x82ec0f0)~INNER 'AutoCommit' 0) thr#8152008
toggle_autocommit: init_done not set, no action
<- STORE= 1 at /home/nmisch/sw/cpan/lib/perl5/i486-linux-gnu-thread-multi/DBI.pm line 723
-> STORE for DBD::Sybase::db (DBI::db=HASH(0x82ec0f0)~INNER 'Username' 'nmtest') thr#8152008
STORE DBI::db=HASH(0x82ec0f0) 'Username' => 'nmtest'
<- STORE= 1 at /home/nmisch/sw/cpan/lib/perl5/i486-linux-gnu-thread-multi/DBI.pm line 726 via at minimal-sybase.pl line 7
-> STORE for DBD::Sybase::db (DBI::db=HASH(0x82ec0f0)~INNER 'syb_chained_txn' 1) thr#8152008
syb_alloc_cmd() -> CS_COMMAND 82f0fc0 for CS_CONNECTION 82f0e70
syb_db_commit() -> ct_command(
COMMIT TRAN
)
syb_db_commit() -> ct_send() OK
servermsg_cb -> number=3902 severity=16 state=1 line=2 server=SQL2008TEST text=The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.
syb_db_commit() -> ct_results(4048) == 1
syb_db_commit() -> ct_results(4046) == 1
syb_db_STORE() -> syb_chained_txn => 1
syb_set_options: optSupported = 1
syb_db_STORE() -> syb_chained_txn AutoCommit off CS_OPT_CHAINXACTS(1) => 1
!! ERROR: 3902 'Server message number=3902 severity=16 state=1 line=2 server=SQL2008TEST text=The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION. ' (err#0)
<- STORE= 1 at /home/nmisch/sw/cpan/lib/perl5/i486-linux-gnu-thread-multi/DBI.pm line 726 via at minimal-sybase.pl line 7
DBD::Sybase::db STORE failed: Server message number=3902 severity=16 state=1 line=2 server=SQL2008TEST text=The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION. at /home/nmisch/sw/cpan/lib/perl5/i486-linux-gnu-thread-multi/DBI.pm line 726.
DBD::Sybase::db STORE failed: Server message number=3902 severity=16 state=1 line=2 server=SQL2008TEST text=The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION. at /home/nmisch/sw/cpan/lib/perl5/i486-linux-gnu-thread-multi/DBI.pm line 726.
-> connected in DBD::_::db for DBD::Sybase::db (DBI::db=HASH(0x82ec174)~0x82ec0f0 'dbi:Sybase:' 'nmtest' **** HASH(0x8152c28)) thr#8152008
ERROR: 3902 'Server message number=3902 severity=16 state=1 line=2 server=SQL2008TEST text=The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION. ' (err#0)
<- connected= undef at /home/nmisch/sw/cpan/lib/perl5/i486-linux-gnu-thread-multi/DBI.pm line 733
<- connect= DBI::db=HASH(0x82ec174)
-> STORE for DBD::Sybase::db (DBI::db=HASH(0x82ec0f0)~INNER 'dbi_connect_closure' CODE(0x82ebd00)) thr#8152008
STORE DBI::db=HASH(0x82ec0f0) 'dbi_connect_closure' => CODE(0x82ebd00)
ERROR: 3902 'Server message number=3902 severity=16 state=1 line=2 server=SQL2008TEST text=The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION. ' (err#0)
<- STORE= 1 at /home/nmisch/sw/cpan/lib/perl5/i486-linux-gnu-thread-multi/DBI.pm line 742 via at minimal-sybase.pl line 7
!! The ERROR '3902' was CLEARED by call to disconnect method
-> disconnect for DBD::Sybase::db (DBI::db=HASH(0x82ec174)~0x82ec0f0) thr#8152008
syb_alloc_cmd() -> CS_COMMAND 816e610 for CS_CONNECTION 82f0e70
syb_db_rollback() -> ct_command(
ROLLBACK TRAN
)
syb_db_rollback() -> ct_send() OK
servermsg_cb -> number=3903 severity=16 state=1 line=2 server=SQL2008TEST text=The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION.
syb_db_rollback() -> ct_results(4048) == 1
syb_db_rollback() -> ct_results(4046) == 1
syb_db_disconnect() -> ct_close()
!! ERROR: 3903 'Server message number=3903 severity=16 state=1 line=2 server=SQL2008TEST text=The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION. ' (err#0)
<- disconnect= 1 at minimal-sybase.pl line 9
DBD::Sybase::db disconnect failed: Server message number=3903 severity=16 state=1 line=2 server=SQL2008TEST text=The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION. at minimal-sybase.pl line 9.
DBD::Sybase::db disconnect failed: Server message number=3903 severity=16 state=1 line=2 server=SQL2008TEST text=The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION. at minimal-sybase.pl line 9.
<> DESTROY(DBI::db=HASH(0x82ec174)) ignored for outer handle (inner DBI::db=HASH(0x82ec0f0) has ref cnt 1)
-> DESTROY for DBD::Sybase::db (DBI::db=HASH(0x82ec0f0)~INNER) thr#8152008
ERROR: 3903 'Server message number=3903 severity=16 state=1 line=2 server=SQL2008TEST text=The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION. ' (err#0)
<- DESTROY= undef
dbih_clearcom 0x82ec0f0 (com 0x82f01b0, type 2) done.
-- DBI::END ($@: , $!: )
!! The ERROR '3903' was CLEARED by call to disconnect_all method
-> disconnect_all for DBD::Sybase::dr (DBI::dr=HASH(0x820880c)~0x82089a4) thr#8152008
<- disconnect_all= 1 at /home/nmisch/sw/cpan/lib/perl5/i486-linux-gnu-thread-multi/DBI.pm line 751 via at minimal-sybase.pl line 0
! -> DESTROY in DBD::_::common for DBD::Sybase::dr (DBI::dr=HASH(0x82089a4)~INNER) thr#8152008
! <- DESTROY= undef during global destruction
dbih_clearcom 0x820880c (com 0x817e858, type 1) done.
! <> DESTROY for DBI::dr=HASH(0x820880c) ignored (inner handle gone)