[racket] Possible bug with DB virtual-connections and connection-pools

From: Curtis Dutton (curtdutt at gmail.com)
Date: Wed Jun 11 11:40:35 EDT 2014

I ran into a problem while using virtual-connections with
connection-pooling in my webserver.


With a postgres database. If the database itself gets restarted after a
connection is formed from the webserver, then I cannot re-establish a
connection afterword.

In production the database and webserver are on different hosts, but my
development box those the same symptoms.


So here is what I see....

(require db)



(define conn #f)

(define (reset)
  (set! conn (virtual-connection (connection-pool (λ ()
                                                    (postgresql-connect
#:server "localhost"

#:user "postgres"

#:password "postgres"

#:database "test"))
                                                  #:max-idle-connections
5))))


(define (go)
  (query conn "SELECT * FROM test"))

(reset)

(go)
;get results

;now restart my postgres server

(go)
. . tcp-write: error writing
  system error: Unknown error; errno=10054

;ok what now?
(disconnect conn)
(go)
. . tcp-write: error writing
  system error: Unknown error; errno=10054

;now what
(reset)
(go)
;I get my results again


I think what I expect is that the connection would be renegotiated for me.
Or maybe at least renegotiated if I run disconnect afterword. If that isn't
the case, that is fine... How should I handle this case?

Thanks,
   Curtis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140611/d3652845/attachment.html>

Posted on the users mailing list.