Subject: | Errors in OCIServerAttach not being caught |
Attempting to connect to Oracle using DBI->connect, I get an ORA-24327
"need explicit attach before authenticating" error from the Oracle
client. From a DBI trace, I can see that OCIServerAttach failed but the
error was not detected. It was the next call, OCISessionBegin, that
failed and generated the ORA-24327 error.
The effect is that the actual connection error from the OCIServerAttach
call is not reported.
I should underline that there is some kind of underlying Oracle error
unrelated to DBD::Oracle. However I cannot determine what it is because
DBD::Oracle is not trapping the error.
The full tracefile is attached, and the most relevant section is pasted
below:
OCIServerAttach(27d47e0, 27d4128,
"(DESCRIPTION=(ADDRESS=(HOST=destination-host)(PROTOCOL=tcp)(PORT=1521))(CONNECT_DATA=(SID=DESTINATION-SID)))",
92, mode=DEFAULT,0)=ERROR
OCIAttrSet(27d4048,OCI_HTYPE_SVCCTX,
27d47e0,0,Attr=OCI_ATTR_SERVER,27d4128)=SUCCESS
OCIHandleAlloc(27914d0,272efd0,OCI_HTYPE_SESSION,0,0)=SUCCESS
OCIAttrSet(27d38d8,OCI_HTYPE_SESSION,
25cef00,11,Attr=OCI_ATTR_USERNAME,27d4128)=SUCCESS
OCIAttrSet(27d38d8,OCI_HTYPE_SESSION,
25643a0,8,Attr=OCI_ATTR_PASSWORD,27d4128)=SUCCESS
OCISessionBegin(27d4048,27d4128,27d38d8,1,mode=DEFAULT 0)=ERROR
OCIErrorGet(27d4128,1,"<NULL>",7fff793dcf0c,"ORA-24327: need explicit
attach before authenticating a user
",1024,2)=SUCCESS
The test script itself is very simple:
use DBI;
my $dbh =
DBI->connect('dbi:Oracle:host=destination-host;sid=DESTINATION-SID;port=1521',
'userid/pwd', '')
or die "Error: $DBI::errstr";
Using DBI 1.616, DBD::Oracle 1.28 under Red Hat Enterprise Linux 6.1
Subject: | trace.txt |
DBI 1.616-nothread default trace level set to 0x0/10 (pid 857 pi 0) at test.pl line 7
-> DBI->connect(dbi:Oracle:HOST=destination-host;SID=DESTINATION-SID;PORT=1521, USERID, ****, HASH(0x24e0748))
-> DBI->install_driver(Oracle) for linux perl=5.014000 pid=857 ruid=624 euid=624
install_driver: DBD::Oracle version 1.28 loaded from /opt/apps/local/GSperl/lib/site_perl/5.14.0/x86_64-linux-ld/DBD/Oracle.pm
New 'DBI::dr' (for DBD::Oracle::dr, parent='', id=undef)
dbih_setup_handle(DBI::dr=HASH(0x25c9610)=>DBI::dr=HASH(0x25c9b50), DBD::Oracle::dr, 0, Null!)
dbih_make_com(Null!, 0, DBD::Oracle::dr, 200, 0) thr#0
dbih_setup_attrib(DBI::dr=HASH(0x25c9b50), Err, Null!) SCALAR(0x25c30b8) (already defined)
dbih_setup_attrib(DBI::dr=HASH(0x25c9b50), State, Null!) SCALAR(0x262e480) (already defined)
dbih_setup_attrib(DBI::dr=HASH(0x25c9b50), Errstr, Null!) SCALAR(0x25c3070) (already defined)
dbih_setup_attrib(DBI::dr=HASH(0x25c9b50), TraceLevel, Null!) 0 (already defined)
dbih_setup_attrib(DBI::dr=HASH(0x25c9b50), FetchHashKeyName, Null!) 'NAME' (already defined)
>> STORE DISPATCH (DBI::dr=HASH(0x25c9610) rc1/1 @3 g2 ima41c pid#857) at /opt/apps/local/GSperl/lib/site_perl/5.14.0/x86_64-linux-ld/DBD/Oracle.pm line 70
-> STORE in DBD::_::common for DBD::Oracle::dr (DBI::dr=HASH(0x25c9610)~0x25c9b50 'ShowErrorStatement' 1)
STORE DBI::dr=HASH(0x25c9b50) 'ShowErrorStatement' => 1
<- STORE= ( 1 ) [1 items] at /opt/apps/local/GSperl/lib/site_perl/5.14.0/x86_64-linux-ld/DBD/Oracle.pm line 70
install_method DBI::db::ora_lob_read
install_method DBI::db::ora_lob_write
install_method DBI::db::ora_lob_append
install_method DBI::db::ora_lob_trim
install_method DBI::db::ora_lob_length
install_method DBI::db::ora_lob_chunk_size
install_method DBI::db::ora_lob_is_init
install_method DBI::db::ora_nls_parameters
install_method DBI::db::ora_can_unicode
install_method DBI::st::ora_fetch_scroll
install_method DBI::st::ora_scroll_position
install_method DBI::st::ora_ping
install_method DBI::st::ora_stmt_type_name
install_method DBI::st::ora_stmt_type
<- install_driver= DBI::dr=HASH(0x25c9610)
>> connect DISPATCH (DBI::dr=HASH(0x25c9610) rc2/3 @5 g2 ima8001 pid#857) at /opt/apps/local/GSperl/lib/site_perl/5.14.0/x86_64-linux-ld/DBI.pm line 665
-> connect for DBD::Oracle::dr (DBI::dr=HASH(0x25c9610)~0x25c9b50 'HOST=destination-host;SID=DESTINATION-SID;PORT=1521' 'USERID' **** HASH(0x25da030))
>> trace_msg DISPATCH (DBI::dr=HASH(0x25c9b50) rc1/2 @2 g2 ima5 pid#857) at /opt/apps/local/GSperl/lib/site_perl/5.14.0/x86_64-linux-ld/DBD/Oracle.pm line 216 via at ./test.pl line 23
1 -> trace_msg in DBD::_::common for DBD::Oracle::dr (DBI::dr=HASH(0x25c9b50)~INNER 'connect using '(DESCRIPTION=(ADDRESS=(HOST=destination-host)(PROTOCOL=tcp)(PORT=1521))(CONNECT_DATA=(SID=DESTINATION-SID)))'')
connect using '(DESCRIPTION=(ADDRESS=(HOST=destination-host)(PROTOCOL=tcp)(PORT=1521))(CONNECT_DATA=(SID=DESTINATION-SID)))'1 <- trace_msg= ( 1 ) [1 items] at /opt/apps/local/GSperl/lib/site_perl/5.14.0/x86_64-linux-ld/DBD/Oracle.pm line 216 via at ./test.pl line 23
New 'DBI::db' (for DBD::Oracle::db, parent=DBI::dr=HASH(0x25c9b50), id=undef)
dbih_setup_handle(DBI::db=HASH(0x272d338)=>DBI::db=HASH(0x272d3e0), DBD::Oracle::db, 262e888, Null!)
dbih_make_com(DBI::dr=HASH(0x25c9b50), 25d1180, DBD::Oracle::db, 368, 272d4b8) thr#0
dbih_setup_attrib(DBI::db=HASH(0x272d3e0), Err, DBI::dr=HASH(0x25c9b50)) SCALAR(0x2637988) (already defined)
dbih_setup_attrib(DBI::db=HASH(0x272d3e0), State, DBI::dr=HASH(0x25c9b50)) SCALAR(0x2637a48) (already defined)
dbih_setup_attrib(DBI::db=HASH(0x272d3e0), Errstr, DBI::dr=HASH(0x25c9b50)) SCALAR(0x26379e8) (already defined)
dbih_setup_attrib(DBI::db=HASH(0x272d3e0), TraceLevel, DBI::dr=HASH(0x25c9b50)) 0 (already defined)
dbih_setup_attrib(DBI::db=HASH(0x272d3e0), FetchHashKeyName, DBI::dr=HASH(0x25c9b50)) 'NAME' (already defined)
dbih_setup_attrib(DBI::db=HASH(0x272d3e0), HandleSetErr, DBI::dr=HASH(0x25c9b50)) undef (not defined)
dbih_setup_attrib(DBI::db=HASH(0x272d3e0), HandleError, DBI::dr=HASH(0x25c9b50)) undef (not defined)
dbih_setup_attrib(DBI::db=HASH(0x272d3e0), ReadOnly, DBI::dr=HASH(0x25c9b50)) undef (not defined)
dbih_setup_attrib(DBI::db=HASH(0x272d3e0), Profile, DBI::dr=HASH(0x25c9b50)) undef (not defined)
OCIAttrSet(0,OCI_HTYPE_SESSION, 7fae1475f267,7,Attr=OCI_ATTR_DRIVER_NAME,0)=INVALID_HANDLE
Environment variables:
HOSTNAME=hostname
LC_MONETARY=en_US.ISO8859-1
SELINUX_ROLE_REQUESTED=
TERM=xterm
SHELL=/bin/bash
HISTSIZE=1000
SSH_CLIENT=10.1.1.1 37965 22
SELINUX_USE_CURRENT_RANGE=
LC_NUMERIC=en_US.ISO8859-1
QTDIR=/usr/lib64/qt-3.3
OLDPWD=/tmp
QTINC=/usr/lib64/qt-3.3/include
SSH_TTY=/dev/pts/0
USER=username
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:
MAIL=/var/spool/mail/username
PATH=/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/username/bin
LC_MESSAGES=C
LC_COLLATE=en_US.ISO8859-1
PWD=/opt/apps/gs/scripts
LANG=en_US.UTF-8
KDE_IS_PRELINKED=1
KDEDIRS=/usr
SELINUX_LEVEL_REQUESTED=
HISTCONTROL=ignoredups
KRB5CCNAME=FILE:/tmp/krb5cc_624_uHQwVh
SHLVL=1
HOME=/home/username
LOGNAME=username
QTLIB=/usr/lib64/qt-3.3/lib
CVS_RSH=ssh
SSH_CONNECTION=10.1.1.1 37345 1.1.1.1 22
LC_CTYPE=en_US.ISO8859-1
LESSOPEN=|/usr/bin/lesspipe.sh %s
LC_TIME=en_US.ISO8859-1
G_BROKEN_FILENAMES=1
_=./test.pl
ORACLE_HOME=/orahome/oracle/product/11.2.0/client_1
OCINlsEnvironmentVariableGet(1,0,93,0,2)=SUCCESS
OCINlsEnvironmentVariableGet(1,0,94,0,2)=SUCCESS
OCIEnvNlsEnvCreate(272efb0,OBJECT,2,0,0,0,0,0,0,1,1)=SUCCESS
OCIHandleAlloc(27914d0,272efb8,OCI_HTYPE_ERROR,0,0)=SUCCESS
OCIAttrGet(27914d0,OCI_HTYPE_ENV,7fae1496ad00,0,31,27d4128)=SUCCESS
OCIAttrGet(27914d0,OCI_HTYPE_ENV,7fae1496ad02,0,262,27d4128)=SUCCESS
charset id=1, name=US7ASCII, ncharset id=1, name=US7ASCII (csid: utf8=871 al32utf8=873)
OCIHandleAlloc(27914d0,272efc0,OCI_HTYPE_SERVER,0,0)=SUCCESS
OCIHandleAlloc(27914d0,272efc8,OCI_HTYPE_SVCCTX,0,0)=SUCCESS
OCIServerAttach(27d47e0, 27d4128, "(DESCRIPTION=(ADDRESS=(HOST=destination-host)(PROTOCOL=tcp)(PORT=1521))(CONNECT_DATA=(SID=DESTINATION-SID)))", 92, mode=DEFAULT,0)=ERROR
OCIAttrSet(27d4048,OCI_HTYPE_SVCCTX, 27d47e0,0,Attr=OCI_ATTR_SERVER,27d4128)=SUCCESS
OCIHandleAlloc(27914d0,272efd0,OCI_HTYPE_SESSION,0,0)=SUCCESS
OCIAttrSet(27d38d8,OCI_HTYPE_SESSION, 25cef00,11,Attr=OCI_ATTR_USERNAME,27d4128)=SUCCESS
OCIAttrSet(27d38d8,OCI_HTYPE_SESSION, 25643a0,8,Attr=OCI_ATTR_PASSWORD,27d4128)=SUCCESS
OCISessionBegin(27d4048,27d4128,27d38d8,1,mode=DEFAULT 0)=ERROR
OCIErrorGet(27d4128,1,"<NULL>",7fff793dcf0c,"ORA-24327: need explicit attach before authenticating a user
",1024,2)=SUCCESS
OCIErrorGet after OCISessionBegin (er1:ok): -1, 24327: ORA-24327: need explicit attach before authenticating a user
OCIErrorGet(27d4128,2,"<NULL>",7fff793dcf0c,"ORA-24327: need explicit attach before authenticating a user
",1024,2)=NO_DATA
OCIServerDetach(27d47e0,27d4128,mode=DEFAULT,0)=SUCCESS
OCIHandleFree(27d38d8,OCI_HTYPE_SESSION)=SUCCESS
OCIHandleFree(27d47e0,OCI_HTYPE_SERVER)=SUCCESS
OCIHandleFree(27d4128,OCI_HTYPE_ERROR)=SUCCESS
OCIHandleFree(27d4048,OCI_HTYPE_SVCCTX)=SUCCESS
OCIHandleFree(27914d0,OCI_HTYPE_ENV)=SUCCESS
>> DESTROY DISPATCH (DBI::db=HASH(0x272d338) rc1/1 @1 g2 ima10004 pid#857) at /opt/apps/local/GSperl/lib/site_perl/5.14.0/x86_64-linux-ld/DBI.pm line 665 via at ./test.pl line 23
<> DESTROY(DBI::db=HASH(0x272d338)) ignored for outer handle (inner DBI::db=HASH(0x272d3e0) has ref cnt 1)
>> DESTROY DISPATCH (DBI::db=HASH(0x272d3e0) rc1/1 @1 g2 ima10004 pid#857) at /opt/apps/local/GSperl/lib/site_perl/5.14.0/x86_64-linux-ld/DBI.pm line 665 via at ./test.pl line 23
-> DESTROY for DBD::Oracle::db (DBI::db=HASH(0x272d3e0)~INNER)
DESTROY for DBI::db=HASH(0x272d3e0) ignored - handle not initialised
ERROR: 24327 'ORA-24327: need explicit attach before authenticating a user (DBD ERROR: OCISessionBegin)' (err#1)
<- DESTROY= ( undef ) [1 items] at /opt/apps/local/GSperl/lib/site_perl/5.14.0/x86_64-linux-ld/DBI.pm line 665 via at ./test.pl line 23
DESTROY (dbih_clearcom) (dbh 0x272d3e0, com 0x272ef10, imp DBD::Oracle::db):
FLAGS 0x102011: COMSET Warn PrintWarn ShowErrorStatement
ERR 24327
ERRSTR 'ORA-24327: need explicit attach before authenticating a user (DBD ERROR: OCISessionBegin)'
PARENT DBI::dr=HASH(0x25c9b50)
KIDS 0 (0 Active)
dbih_clearcom 0x272d3e0 (com 0x272ef10, type 2) done.
!! ERROR: 24327 'ORA-24327: need explicit attach before authenticating a user (DBD ERROR: OCISessionBegin)' (err#0)
<- connect= ( undef ) [1 items] at /opt/apps/local/GSperl/lib/site_perl/5.14.0/x86_64-linux-ld/DBI.pm line 665
-> $DBI::errstr (&) FETCH from lasth=HASH
>> DBD::Oracle::dr::errstr
<- $DBI::errstr= 'ORA-24327: need explicit attach before authenticating a user (DBD ERROR: OCISessionBegin)'
DBI connect('HOST=destination-host;SID=DESTINATION-SID;PORT=1521','USERID',...) failed: ORA-24327: need explicit attach before authenticating a user (DBD ERROR: OCISessionBegin)
-- DBI::END ($@: , $!: )
>> disconnect_all DISPATCH (DBI::dr=HASH(0x25c9610) rc1/3 @1 g2 ima801 pid#857) at /opt/apps/local/GSperl/lib/site_perl/5.14.0/x86_64-linux-ld/DBI.pm line 744 via at /opt/apps/local/GSperl/lib/5.14.0/Carp.pm line 79
!! ERROR: 24327 CLEARED by call to disconnect_all method
-> disconnect_all for DBD::Oracle::dr (DBI::dr=HASH(0x25c9610)~0x25c9b50)
<- disconnect_all= ( ) [0 items] (not implemented) at /opt/apps/local/GSperl/lib/site_perl/5.14.0/x86_64-linux-ld/DBI.pm line 744 via at /opt/apps/local/GSperl/lib/5.14.0/Carp.pm line 79
! >> DESTROY DISPATCH (DBI::dr=HASH(0x25c9b50) rc1/1 @1 g2 ima10004 pid#857) during global destruction
! -> DESTROY in DBD::_::common for DBD::Oracle::dr (DBI::dr=HASH(0x25c9b50)~INNER)
! <- DESTROY= ( undef ) [1 items] during global destruction
DESTROY (dbih_clearcom) (drh 0x25c9610, com 0x25d1180, imp global destruction):
FLAGS 0x102215: COMSET Active Warn PrintWarn ShowErrorStatement AutoCommit
PARENT undef
KIDS 0 (0 Active)
dbih_clearcom 0x25c9610 (com 0x25d1180, type 1) done.
! >> DESTROY DISPATCH (DBI::dr=HASH(0x25c9610) rc1/1 @1 g2 ima10004 pid#857) during global destruction
! <> DESTROY for DBI::dr=HASH(0x25c9610) ignored (inner handle gone)