Hi!
I am having a problem with connection pooling and old dead connections not
being removed as expected.
I am setting up and caching my connections like this:
> module Test
> class M3DB
> def self.connection(connection_string)
> $db_connection_cache ||= {}
> return $db_connection_cache[connection_string] if
> $db_connection_cache.has_key?(connection_string)
> db = Sequel.connect(connection_string, :max_connections => 6)
> db.identifier_output_method = nil
> db.identifier_input_method = nil
> $db_connection_cache[connection_string] = db
> end
> end
> end
Then using it for example like this:
> Test::M3DB.connection(connectionstring)[:TABLE]
> .where(:FIELD => value)
> .select(:PROP1, :PROP2)
What I am seeing then is that if the connection gets broken the old
connections are not being removed from the pool and every time I try to
issue a new query I get the following exception:
> --------
> ## Error:
> java.sql.SQLException: The connection does not exist.
> ## Backtrace:
> com.ibm.as400.access.JDError.throwSQLException(JDError.java:415)
>
> com.ibm.as400.access.AS400JDBCConnection.checkOpen(AS400JDBCConnection.java:460)
>
> com.ibm.as400.access.AS400JDBCConnection.sendAndReceive(AS400JDBCConnection.java:2941)
> com.ibm.as400.access.AS400JDBCStatement.close(AS400JDBCStatement.java:474)
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> --------
I have also tried using connection_validation, but I did not see any
difference to how the dead connections where handled. I was getting the
same Exception then as well.
> module testingTest
> class M3DB
> def self.connection(connection_string)
> $db_connection_cache ||= {}
> return $db_connection_cache[connection_string] if
> $db_connection_cache.has_key?(connection_string)
> db = Sequel.connect(connection_string, :max_connections => 6)
> db.extension(:connection_validator)
> db.identifier_output_method = nil
> db.identifier_input_method = nil
> $db_connection_cache[connection_string] = db
> end
> end
> end
If I use db.pool.connection_validation_timeout = -1 I can see the dead
connections being cleared, but the performance penalty is quite high so I
would like to avoid that if possible.
How do you suggest we handle this scenario?
The database in use is a DB2, so we are using jdbc:as400
Regards, Mikael
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.