On Tuesday, August 19, 2014 10:43:26 AM UTC-7, Shane Turner wrote:
>
> I"ve recently starting using sinatra and sequel for some rest based 
> service and I love the simplicity of Sequel.
> However, when the system is idle for a while ( I haven't determined exact 
> idle time, a couple of days), any new connections will throw the following
> exception and has to be rebooted to solve the problem.  Can you determine 
> if this is a sequel thing or a JTDS driver issue?
>

The disconnecting of the connection is a JTDS driver, database, or network 
issue, depending on what is causing the disconnect.

However, the main issue is that Sequel doesn't recognize this as a 
disconnect error (as DatabaseError is raised instead of 
DatabaseDisconnectError).  If Sequel recognizes this as a disconnect error, 
if a request raises a disconnect error, that connection will be removed 
from the pool, and a new connection will be made on the next request.  You 
can also use the connection_validator extension to validate connections 
before use.

Can you try this patch:

diff --git a/lib/sequel/adapters/jdbc/jtds.rb 
b/lib/sequel/adapters/jdbc/jtds.rb
index 65963b4b..e3a50d7 100644
--- a/lib/sequel/adapters/jdbc/jtds.rb
+++ b/lib/sequel/adapters/jdbc/jtds.rb
@@ -26,6 +26,10 @@ module Sequel
           false
         end

+        def disconnect_error?(exception, opts)
+          super || exception.message =~ /\AInvalid state, the Connection 
object is closed\.\z/
+        end
+
         # Handle nil values by using setNull with the correct parameter 
type.
         def set_ps_arg_nil(cps, i)
           cps.setNull(i, cps.getParameterMetaData.getParameterType(i))

Thanks,
Jeremy

-- 
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/d/optout.

Reply via email to