You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Chris Hostetter <ho...@fucit.org> on 2011/10/01 02:48:14 UTC

Re: DataImportHandler using new connection on each query

: > Noble? Shalin?  what's the point of throwing away a connection that's been
: > in use for more then 10 seconds?

: Hoss, as others have noted, DIH throws away connections which have been idle
: for more than the timeout value (10 seconds). The jdbc standard way of
: checking for a valid connection is not implemented or incorrectly
: implemented by many drivers. So, either you can execute a query and get an
: exception and try to determine if the exception was a case of an invalid
: connection (which again is sometimes different from driver to driver) or
: take the easy way out and throw away connections idle for more than 10
: seconds, which is what we went for.

Hmmm...

a) at a minimum this seems like it should be a config option -- why punish 
people using "good" jdbc drivers?

b) you keep refering to this time out in relation to connections being 
*idle* longer then 10 seconds, but unless i'm missing something that's not 
what it's doing at all.  

The only time connLastUsed is assigned to is when getConnection() is 
called - so even if a connection has only been idle for 1 pico-second, it 
will still be closed/reopened if the total amount of time it was used 
before being idle was more then 1 second -- that was the scenerio 
described in the first message of this thread...

second 000: app starts
second 006: ResultSetIterator constructed on queryA
second 007: getConnection() called, conn initalized, connLastUsed = 007
   ... conn in use for a while while iterating over results...
second 099: done iterating over ResultSetIterator
second 100: ResultSetIterator constructed on queryB
second 101: getConnection() called again...

...at second #101, that connection has really only been idle for 2 
seconds, but connLastUsed hasn't been updated for 94 seconds, so it 
forces a new connection for no reason.

If the goal is to track how long the connection has been idle, shouldn't 
every method in ResultSetIterator update connLastUsed ?





-Hoss