Re: [Sqlrelay-discussion] Blocking call when DB is offline
Brought to you by:
mused
From: Z S. <sha...@ho...> - 2012-05-11 19:24:11
|
Hi Dave, Thank you very much for your reply. I have also tried the "sqlrcon_setTimeout(sec,usec) " before calling sqlrcur_sendQuery, but it does not succeed (still blocking). This is my sqlrelay.conf: " <?xml version="1.0"?> <!DOCTYPE instances SYSTEM "sqlrelay.dtd"> <instances> <!-- Regular SQL Relay Instance --> <instance id="hspgw" port="9000" socket="/tmp/example.socket" dbase="oracle8" connections="3" maxconnections="15" maxqueuelength="5" growby="1" ttl="60" maxsessioncount="1000" endofsession="commit" sessiontimeout="600" runasuser="nobody" runasgroup="nobody" cursors="5" authtier="listener" handoff="pass" deniedips="" allowedips="" debug="none" maxquerysize="65536" maxstringbindvaluelength="4000" maxlobbindvaluelength="71680" idleclienttimeout="-1" maxlisteners="-1" listenertimeout="0" reloginatstart="no" timequeriessec="-1" timequeriesusec="-1" fakeinputbindvariables="no" translatebindvariables="no" isolationlevel="read committed" ignoreselectdatabase="no"> <users> <user user="BTO_SPP" password="BTO_SPP"/> </users> <connections> <connection connectionid="db1" string="user=BTO_SPP;password=bto_spp;oracle_sid=SPPPO2;" metric="1" behindloadbalancer="no"/> </connections> </instance> </instances> " Btw, I find out that the blocking happens by a call to bool sqlrcursor::runQuery(const char *query) { // send the query if (sendQueryInternal(query)) { sendInputBinds(); sendOutputBinds(); sendGetColumnInfo(); sqlrc->flushWriteBuffer(); if (rsbuffersize) { if (processResultSet(false,rsbuffersize-1)) { return true; } } else { if (processResultSet(true,0)) { <----- blocking return true; } } } return false; } => step into, finally: int32_t sqlrcursor::getShort(uint16_t *integer) { if (!sqlrc->cs->isUsingNonBlockingMode()){ // if the result set is coming from a cache file, read from // the file, if not, read from the server if (cachesource && cachesourceind) { return cachesource->read(integer); <--- blocking } else { return sqlrc->cs->read(integer); <--- blocking } } At the same time, I see there are different read() methods defined in filedescripter.C, some of which has the possibility to set timeout in secs, and usec. Do the parameters (sec, usec) affect the behavior? Cheers, Shan Date: Fri, 11 May 2012 14:30:43 -0400 From: dav...@fi... To: sql...@li... Subject: Re: [Sqlrelay-discussion] Blocking call when DB is offline Hi Shan, There is one option that might help... On the client side there is a sqlrcon_setTimeout(sec,usec) function that allows you to set the number of seconds and microseconds that the client will wait while connecting. If the connection doesn't succeed within that amount of time, then it will fall through. You could try that, but I'm not sure that it will help in this case. It looks like something is causing the second query to wait for an available database connection, and it gets stuck waiting forever. Could you post your sqlrelay.conf file? I'll do some tests and let you know what I find. Dave dav...@fi... On 05/10/2012 06:29 AM, Z Shan wrote: Hi, My application needs to talk with Oracle DB. To improve performance, I use SQLRelay as intermediate layer. Recently, I have met with following problem : 1 Both SQLRelay and Oracle DB are started 2 Send query from my App (use 'sqlrcur_sendQuery') => OK 3 Shutdown Oracle DB 4 Send query again from my App, the call on "sqlrcur_sendQuery" is blocked (no return). 5 Turn on Oracle DB again 6 The old call to sqlrcur_sendQuery is returned. Further queries can all be processed. I activated log flag of SqlRelay (SQLRDEBUG=ON), and see following output: " Connecting to listener... Inet socket: 10.10.10.120:9000 Authenticating with listener : bto_spp:bto_spp Waiting for auth success/failure... No authentication error. Must Reconnect. Reconnecting to server: 10.10.10.120 inet port: 33681 Connected. Authenticating with connection : bto_spp:bto_spp Waiting for auth success/failure... No authentication error. Sending Query: SELECT * FROM HSPGW_CONFIG_VIEW WHERE ZONE_ID = 1682 AND IS_ENABLED = 1 AND TARIFF_ID = 16 Length: 90 Requesting a new cursor. Sending 0 Input Bind Variables: Sending Output Bind Variables: Send Column Info: yes Skipping and Fetching Skipping 0 rows Fetching 0 rows " Is there any way to let 'sqlrcur_sendQuery' return after certain time when the connection to DB is failed (like setting a timeout)? Otherwise the whole APP will hang as far as the DB is offline. Any help will be appreciated. Shan ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________________ Unlimited Disk, Data Transfer, PHP/MySQL Domain Hosting http://www.doteasy.com _______________________________________________ Sqlrelay-discussion mailing list Sql...@li... https://lists.sourceforge.net/lists/listinfo/sqlrelay-discussion _______________________________________________________ Unlimited Disk, Data Transfer, PHP/MySQL Domain Hosting http://www.doteasy.com ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Sqlrelay-discussion mailing list Sql...@li... https://lists.sourceforge.net/lists/listinfo/sqlrelay-discussion |