Thread: [cx-oracle-users] best way to detect and recover broken connection?
Brought to you by:
atuining
From: Mark H. <mh...@pi...> - 2006-12-04 08:37:58
|
Here's kind of a general connection question. I've got an application server (xml-rpc based) with a long-lived persistent connection. Of course, the appserver needs to handle the eventuality that the connection will be closed at some time. What's the best way to handle this? Is there some nice way to globally catch a disconnection and automatically reconnect, or some such? Many TIA! Mark -- Mark Harrison Pixar Animation Studios |
From: Anthony T. <ant...@gm...> - 2006-12-04 14:34:31
|
No, there is no way to globally catch a disconnection. The first time you will be aware of it is when you make a query and the exception "not connected to database" (or something similar) is raised. A number of people perform a "ping" first (execute the statement "select 1 from dual") before attempting their own query. If that query fails, they estabilish a new connection and use that instead. I'm not aware of any other techniques so if anyone else has any to share, please do so. On 12/4/06, Mark Harrison <mh...@pi...> wrote: > Here's kind of a general connection question. > > I've got an application server (xml-rpc based) with > a long-lived persistent connection. > > Of course, the appserver needs to handle the eventuality > that the connection will be closed at some time. > > What's the best way to handle this? Is there some nice > way to globally catch a disconnection and automatically > reconnect, or some such? > > Many TIA! > Mark > > -- > Mark Harrison > Pixar Animation Studios > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > |
From: Frank v. L. <fvl...@ca...> - 2006-12-05 08:14:33
|
We had to deal with a similar problem of loosing a connection. What we do is to store a queue of all queries (updates,inserts, and deletes) made during a transaction. If for some reason the connection is lost before a commit we re connect and execute the queries again in the same order. After a commit we empty the queue for that transaction. This has worked quite well. I must add that we seldom drop a connection. We try to keep transactions and connection time short, but we do not have thousands of transactions a minute. In the past we also used a connection cache. So we have long running open connections that are more likely to disconnect once in a while, in combination with the query queuing. This made the system more responsive when we deal with many transactions as connecting every time gives some overhead. To minimize unexpected connection losses we refreshed the connection once in a while. Frank. Anthony Tuininga wrote: > No, there is no way to globally catch a disconnection. The first time > you will be aware of it is when you make a query and the exception > "not connected to database" (or something similar) is raised. A number > of people perform a "ping" first (execute the statement "select 1 from > dual") before attempting their own query. If that query fails, they > estabilish a new connection and use that instead. I'm not aware of any > other techniques so if anyone else has any to share, please do so. > > On 12/4/06, Mark Harrison <mh...@pi...> wrote: >> Here's kind of a general connection question. >> >> I've got an application server (xml-rpc based) with >> a long-lived persistent connection. >> >> Of course, the appserver needs to handle the eventuality >> that the connection will be closed at some time. >> >> What's the best way to handle this? Is there some nice >> way to globally catch a disconnection and automatically >> reconnect, or some such? >> >> Many TIA! >> Mark >> >> -- >> Mark Harrison >> Pixar Animation Studios >> >> ------------------------------------------------------------------------- >> Take Surveys. Earn Cash. Influence the Future of IT >> Join SourceForge.net's Techsay panel and you'll get the chance to share your >> opinions on IT & business topics through brief surveys - and earn cash >> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV >> _______________________________________________ >> cx-oracle-users mailing list >> cx-...@li... >> https://lists.sourceforge.net/lists/listinfo/cx-oracle-users >> > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users -- -------------------------------------- Frank van Lingen California Institute of Technology CA 91125 Pasadena United States -------------------------------------- Mail Code:356-48 bld :340 Lauritsen email :fvl...@ca... im(aim) :marcellus0872 tel :(+1) 626 395 3862 url :http://www.vanlingen.name/ -------------------------------------- |
From: Miguel M. <mi...@yo...> - 2006-12-04 16:46:41
|
Greetings... On Mon, 04 Dec 2006 00:37:28 -0800, Mark Harrison <mh...@pi...> wrote: > Here's kind of a general connection question. > > I've got an application server (xml-rpc based) with > a long-lived persistent connection. Me too... :-) > > Of course, the appserver needs to handle the eventuality > that the connection will be closed at some time. > > What's the best way to handle this? Is there some nice > way to globally catch a disconnection and automatically > reconnect, or some such? > > Many TIA! > Mark > I just set a class variable with errors I think I should reconnect on, # TNS: 12154 12541 12543 12540 # Database: 1014 1033 1034 1035 1089 1090 1092 # Network: 3113 3114 RECONNECTERRORLIST = [ 12154,12541,12543,12540,1014,1033,1034, 1035,1089,1090,1092,3113,3114,3106 ] then in the method that actually performs the Oracle calls I catch the DatabaseError exceptions and check if the Oracle error is in the list (which is probably incomplete) and try to reconnect and redo the query. Hope that's useful. Miguel C. Miguel Marques, Assistant Manager, Software Systems Developer Development Services, Computing & Network Services York University, Toronto, Ontario, Canada e-mail: miguel at yorku.ca, voice: (416)736-2100x22684 |
From: Laurelin of M. E. <la...@fn...> - 2006-12-04 17:02:58
|
I had earlier requested a "reconnect" method on the connection itself, so that the class instance could transparently "get a new *physical* connection under the covers". I received the following response from Anthony Tuininga: "I'll look into adding this at some point -- assuming there are no hidden gotchas that make it undesirable, of course. If I run into any of those I'll let you know." (quoted from private mail send on 5-Oct-2006). I haven't heard that the changes have been put into the code -- but I haven't heard of any hidden gotchas either, so... -- lauri |
From: Anthony T. <ant...@gm...> - 2006-12-04 17:16:22
|
On 12/4/06, Laurelin of Middle Earth <la...@fn...> wrote: > I had earlier requested a "reconnect" method on the connection itself, > so that the class instance could transparently "get a new *physical* > connection under the covers". I received the following response > from Anthony Tuininga: > > "I'll look into adding this at some point -- > assuming there are no hidden gotchas that make it undesirable, of > course. If I run into any of those I'll let you know." > > (quoted from private mail send on 5-Oct-2006). I haven't heard that > the changes have been put into the code -- but I haven't heard of any > hidden gotchas either, so... Still haven't gotten around to doing this, yet. I'd be interested in the code used by the previous poster as it might point to a simple solution or some hidden gotchas that would need to be documented at least. > -- lauri > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > |