Re: [Sqlrelay-discussion] ping() in Java
Brought to you by:
mused
|
From: David M. <dav...@fi...> - 2005-12-16 16:43:21
|
Maciej,
I just ran some tests and I got the same behavior from python and java.
What version of SQL Relay are you using? Maybe there's a bug in that
version.
Give the test programs below a try and see if you don't get the same
results as the log below shows.
Dave
dav...@fi...
Java test program:
import com.firstworks.sqlrelay.SQLRConnection;
import com.firstworks.sqlrelay.SQLRCursor;
class test {
public static void main(String[] args) {
String host="localhost";
short port=8009;
String socket="";
String user="oracle8test";
String pwd="oracle8test";
//loop three times
for (int a=0; a<3; a++){
SQLRConnection conn = new SQLRConnection(host, port, socket, user,
pwd, 0, 1);
System.out.println("ping"+conn.ping()+". ");
if (conn.ping()){
System.out.println("OK");
}
else{
SQLRCursor cur=new SQLRCursor(conn);
cur.getNullsAsNulls();
String query = "select 1 from dual";
cur.sendQuery(query);
System.out.println("rowcount:"+cur.rowCount());
}
}
}
}
Python test program:
#!/usr/bin/env python
from SQLRelay import PySQLRClient
import sys
import string
host="localhost"
port=8009
socket=""
user="oracle8test"
pwd="oracle8test"
for i in range(0,3):
conn=PySQLRClient.sqlrconnection(host, port, socket, user, pwd, 0, 1)
print "ping", conn.ping(), ". "
if conn.ping():
print "OK"
else:
cur=PySQLRClient.sqlrcursor(conn)
cur.getNullsAsNone()
query="select 1 from dual"
cur.sendQuery(query)
print "rowcount:", cur.rowCount()
And here's a log of my test:
**** oracle and sqlrelay are running *****
[mused@localhost java]$ ps -efa | grep ora
root 2400 2386 0 Dec15 ? 00:00:01 hald-addon-storage
mused 15155 1 0 11:03 ? 00:00:00 sqlr-listener -id
oracle8test -config /usr/local/firstworks/etc/sqlrelay.conf
mused 15160 1 0 11:03 ? 00:00:06 sqlr-connection-oracle8
-id oracle8test -connectionid db
-config /usr/local/firstworks/etc/sqlrelay.conf
mused 15164 1 0 11:03 ? 00:00:07 sqlr-connection-oracle8
-id oracle8test -connectionid db
-config /usr/local/firstworks/etc/sqlrelay.conf
mused 15168 1 0 11:03 ? 00:00:06 sqlr-connection-oracle8
-id oracle8test -connectionid db
-config /usr/local/firstworks/etc/sqlrelay.conf
mused 15170 1 0 11:03 ? 00:00:00 sqlr-scaler -id
oracle8test -config /usr/local/firstworks/etc/sqlrelay.conf
oracle 16613 1 0 11:21 ? 00:00:00 ora_pmon_ora1
oracle 16615 1 0 11:21 ? 00:00:00 ora_mman_ora1
oracle 16617 1 0 11:21 ? 00:00:00 ora_dbw0_ora1
oracle 16619 1 0 11:21 ? 00:00:00 ora_lgwr_ora1
oracle 16621 1 0 11:21 ? 00:00:00 ora_ckpt_ora1
oracle 16623 1 0 11:21 ? 00:00:00 ora_smon_ora1
oracle 16625 1 0 11:21 ? 00:00:00 ora_reco_ora1
oracle 16627 1 0 11:21 ? 00:00:00 ora_cjq0_ora1
oracle 16629 1 0 11:21 ? 00:00:00 ora_d000_ora1
oracle 16631 1 0 11:21 ? 00:00:00 ora_s000_ora1
oracle 16656 1 0 11:21 ? 00:00:00 ora_qmnc_ora1
oracle 16666 1 0 11:21 ? 00:00:01 ora_mmon_ora1
oracle 16668 1 0 11:21 ? 00:00:00 ora_mmnl_ora1
oracle 16715 1 0 11:21 ?
00:00:00 /u01/app/oracle/product/10.1.0/bin/tnslsnr LISTENER -inherit
oracle 16817 1 0 11:23 ? 00:00:00 oracleora1 (LOCAL=NO)
oracle 16820 1 0 11:23 ? 00:00:00 oracleora1 (LOCAL=NO)
oracle 16823 1 0 11:23 ? 00:00:00 oracleora1 (LOCAL=NO)
oracle 17303 1 0 11:32 ? 00:00:00 ora_q000_ora1
mused 17511 32183 0 11:36 pts/3 00:00:00 grep ora
**** bounce the database ****
[mused@localhost java]$ sudo /etc/rc.d/init.d/oracle stop
SQL*Plus: Release 10.1.0.2.0 - Production on Fri Dec 16 11:36:40 2005
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL> ERROR:
ORA-12162: TNS:net service name is incorrectly specified
SQL> ORA-12162: TNS:net service name is incorrectly specified
SQL> Database "" shut down.
SQL*Plus: Release 10.1.0.2.0 - Production on Fri Dec 16 11:36:40 2005
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL> Connected.
SQL> Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> Disconnected from Oracle Database 10g Enterprise Edition Release
10.1.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options
Database "ora1" shut down.
LSNRCTL for Linux: Version 10.1.0.2.0 - Production on 16-DEC-2005
11:36:58
Copyright (c) 1991, 2004, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))
The command completed successfully
[mused@localhost java]$ sudo /etc/rc.d/init.d/oracle start
SQL*Plus: Release 10.1.0.2.0 - Production on Fri Dec 16 11:37:08 2005
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL> ERROR:
ORA-12162: TNS:net service name is incorrectly specified
SQL> ORA-12162: TNS:net service name is incorrectly specified
SQL>
Database "" warm started.
SQL*Plus: Release 10.1.0.2.0 - Production on Fri Dec 16 11:37:08 2005
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL> Connected to an idle instance.
SQL> ORACLE instance started.
Total System Global Area 188743680 bytes
Fixed Size 778036 bytes
Variable Size 162537676 bytes
Database Buffers 25165824 bytes
Redo Buffers 262144 bytes
Database mounted.
Database opened.
SQL> Disconnected from Oracle Database 10g Enterprise Edition Release
10.1.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options
Database "ora1" warm started.
LSNRCTL for Linux: Version 10.1.0.2.0 - Production on 16-DEC-2005
11:37:43
Copyright (c) 1991, 2004, Oracle. All rights reserved.
Starting /u01/app/oracle/product/10.1.0/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.1.0.2.0 - Production
System parameter file
is /u01/app/oracle/product/10.1.0/network/admin/listener.ora
Log messages written
to /u01/app/oracle/product/10.1.0/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))
Listening on:
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.1.0.2.0 -
Production
Start Date 16-DEC-2005 11:37:44
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter
File /u01/app/oracle/product/10.1.0/network/admin/listener.ora
Listener Log
File /u01/app/oracle/product/10.1.0/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this
service...
Service "ora1" has 1 instance(s).
Instance "ora1", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
**** run the python test ****
[mused@localhost java]$ ./test.py
ping 0 .
rowcount: 1
ping 0 .
rowcount: 1
ping 0 .
rowcount: 1
**** run it again now that sqlrelay has reconnected ****
[mused@localhost java]$ ./test.py
ping 1 .
OK
ping 1 .
OK
ping 1 .
OK
**** bounce the database ****
[mused@localhost java]$ sudo /etc/rc.d/init.d/oracle stop
SQL*Plus: Release 10.1.0.2.0 - Production on Fri Dec 16 11:38:31 2005
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL> ERROR:
ORA-12162: TNS:net service name is incorrectly specified
SQL> ORA-12162: TNS:net service name is incorrectly specified
SQL> Database "" shut down.
SQL*Plus: Release 10.1.0.2.0 - Production on Fri Dec 16 11:38:31 2005
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL> Connected.
SQL> Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> Disconnected from Oracle Database 10g Enterprise Edition Release
10.1.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options
Database "ora1" shut down.
LSNRCTL for Linux: Version 10.1.0.2.0 - Production on 16-DEC-2005
11:38:45
Copyright (c) 1991, 2004, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))
The command completed successfully
[mused@localhost java]$ sudo /etc/rc.d/init.d/oracle start
SQL*Plus: Release 10.1.0.2.0 - Production on Fri Dec 16 11:38:50 2005
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL> ERROR:
ORA-12162: TNS:net service name is incorrectly specified
SQL> ORA-12162: TNS:net service name is incorrectly specified
SQL>
Database "" warm started.
SQL*Plus: Release 10.1.0.2.0 - Production on Fri Dec 16 11:38:50 2005
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL> Connected to an idle instance.
SQL> ORACLE instance started.
Total System Global Area 188743680 bytes
Fixed Size 778036 bytes
Variable Size 162537676 bytes
Database Buffers 25165824 bytes
Redo Buffers 262144 bytes
Database mounted.
Database opened.
SQL> Disconnected from Oracle Database 10g Enterprise Edition Release
10.1.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options
Database "ora1" warm started.
LSNRCTL for Linux: Version 10.1.0.2.0 - Production on 16-DEC-2005
11:39:06
Copyright (c) 1991, 2004, Oracle. All rights reserved.
Starting /u01/app/oracle/product/10.1.0/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.1.0.2.0 - Production
System parameter file
is /u01/app/oracle/product/10.1.0/network/admin/listener.ora
Log messages written
to /u01/app/oracle/product/10.1.0/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))
Listening on:
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.1.0.2.0 -
Production
Start Date 16-DEC-2005 11:39:06
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter
File /u01/app/oracle/product/10.1.0/network/admin/listener.ora
Listener Log
File /u01/app/oracle/product/10.1.0/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this
service...
Service "ora1" has 1 instance(s).
Instance "ora1", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
**** run the java test ****
[mused@localhost java]$ /usr/java/jdk1.5.0_04/bin/java
-classpath /usr/local/firstworks/java/sqlrelay.jar:./ test
pingfalse.
rowcount:1
pingfalse.
rowcount:1
pingfalse.
rowcount:1
**** run it again now that sqlrelay has reconnected ****
[mused@localhost java]$ /usr/java/jdk1.5.0_04/bin/java
-classpath /usr/local/firstworks/java/sqlrelay.jar:./ test
pingtrue.
OK
pingtrue.
OK
pingtrue.
OK
On Fri, 2005-12-16 at 10:22 -0500, David Muse wrote:
> Hey Maciej,
>
> If SQL Relay lost contact with the database during the backup and no
> other queries had been run, then I'd expect the ping to return false,
> and then the next query to cause SQL Relay to reconnect, run the query
> and return rowcount of 1.
>
> If you have 3 sqlr-connection daemons running, you'd see that behavior 3
> times. After all 3 sqlr-connections have re-established their database
> conections, ping should start returning true.
>
> The behavior your java program exhibits is exactly what I'd expect.
>
> If the python program exhibits different behavior, then maybe there's a
> bug there. Although ping is implemented identically for both API's.
> They just wrap the C++ function.
>
> Does the python program maybe run against a different database, where
> another program may have run queries against the database since the
> backup?
>
> Just to be sure, I'll see if I can simulate the same conditions here and
> let you know what I find out.
>
> Dave
> dav...@fi...
>
> [snip]
> > I understand it, but I think my problem is different. Or maybe I'm wrong?
> > My program runs as follows:
> >
> > import com.firstworks.sqlrelay.SQLRConnection;
> > import com.firstworks.sqlrelay.SQLRCursor;
> >
> > //loop three times
> > for (int a=0; a<=3; a++){
> > SQLRConnection conn = new SQLRConnection(host, port, socket, user, pwd, 0, 1);
> > System.out.println("ping"+conn.ping()+". ");
> >
> > if (conn.ping()){
> > System.out.println("OK");
> > }
> > else{
> > SQLRCursor cur=new SQLRCursor(conn);
> > cur.getNullsAsNulls();
> > String query = "select xxx from xyz";
> > cur.sendQuery(query);
> > System.out.println("rowcount:"+cur.rowCount());
> > }
> > }
> >
> >
> > Today morning (after database backup at night) I've started my program
> > and the result was:
> > ping false. rowcount:1
> > ping false. rowcount:1
> > ping false. rowcount:1
> >
> > Then I've started this program again and the result was:
> > ping true. OK
> > ping true. OK
> > ping true. OK
> >
> > It seems that SQLRelay is connected to database because sendQuery
> > returns some results but ping returns false (bug?).
> > When whole program is executed for the second time (but not in the
> > second loop run) everything starts to work correctly.
> > As far as I've checked this, in python there are no such problems, and
> > ping returns true even in the first run.
> >
> > ---
> > Maciej Wisniowski
> >
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
> > for problems? Stop! Download the new AJAX search engine that makes
> > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> > http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> > _______________________________________________
> > Sqlrelay-discussion mailing list
> > Sql...@li...
> > https://lists.sourceforge.net/lists/listinfo/sqlrelay-discussion
> >
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
> for problems? Stop! Download the new AJAX search engine that makes
> searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> _______________________________________________
> Sqlrelay-discussion mailing list
> Sql...@li...
> https://lists.sourceforge.net/lists/listinfo/sqlrelay-discussion
>
|