On 4/5/2017 2:56 PM, David Storrs wrote:
On Wed, Apr 5, 2017 at 1:39 PM, Marc Kaufmann <[email protected]> wrote:
> Thanks David, that makes a little sense also because it often happens after
> there has been no activity on the server for a while. If it is a stale
> handle, is there something I can do about it?

Get a fresh handle instead of re-using an old one.  I don't know what
this line does:    (define dbc (study-db a-study))   but if it's
returning a cached handle then that's your problem.

Something like this would work:

(define (connect-me)
   (postgresql-connect #:user     "foo"
                       #:database "bar"
                       #:password "baz"
                       #:port     5432
                       ))

(define dbc (connect-me))


(Note that this is illustrative, not necessarily efficient.)

Also, you might want to look into virtual connections and connection pools.

In addition to David's excellent suggestion:

Be aware that the server may close an idle connection, and you may get a stale handle even from a pool. Depending on the DBMS you may need to enable keep-alives and/or change idle connection timeouts on the server so that a pool can keep connections open.

MySQL uses keep-alives by default, but there is a separate idle connection timeout. see https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_wait_timeout

George

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to