3

The suggest url for my redshift server has a ?tcpKeepAlive=true appended to it, so that it looks something like

jdbc:postgresql://myserver:myport/dbname?tcpKeepAlive=true

Now, the RPostgres::dbConnect function has signature

dbConnect(dbname = NULL, host = NULL, port = NULL, password = NULL, user = NULL, ...)

and the man for dbConnect says that

... - Other name-value pairs that describe additional connection options as described at http://www.postgresql.org/docs/9.4/static/libpq-connect.html#LIBPQ-PARAMKEYWORDS

However, the closest connection options I can see to what I'm looking for are

  • keepalives:

    Controls whether client-side TCP keepalives are used. The default value is 1, meaning on, but you can change this to 0, meaning off, if keepalives are not wanted. This parameter is ignored for connections made via a Unix-domain socket.

  • keepalives_idle:

    Controls the number of seconds of inactivity after which TCP should send a keepalive message to the server. A value of zero uses the system default. This parameter is ignored for connections made via a Unix-domain socket, or if keepalives are disabled. It is only supported on systems where the TCP_KEEPIDLE or TCP_KEEPALIVE socket option is available, and on Windows; on other systems, it has no effect.

  • keepalives_interval:

    Controls the number of seconds after which a TCP keepalive message that is not acknowledged by the server should be retransmitted. A value of zero uses the system default. This parameter is ignored for connections made via a Unix-domain socket, or if keepalives are disabled. It is only supported on systems where the TCP_KEEPINTVL socket option is available, and on Windows; on other systems, it has no effect. keepalives_count

And I'm not sure how to use these to mimic the effect of ?tcpKeepAlive=true...

I imagine I could do something like

myConn <- dbConnect(dbname = "dbname",
                    host = "myserver",
                    port = "myport",
                    user = "StevieP",
                    password = "faketown101",
                    keepalives = x,
                    keepalives_idle = y,
                    keepalives_interval = z)

But I'm wondering what values I need to choose for x, y, and z?

StevieP
  • 1,569
  • 12
  • 23
  • This seems more like a question for your database administrator – hadley Jul 02 '15 at 03:47
  • I guess the real question is: how does `?tcpKeepAlive=true` in a postrgresql URL relate to the `keepalives` parameters? – StevieP Jul 02 '15 at 06:59
  • I don't think that's a postgres convention, but a JDBC convention. Again, your DBA should be able to help you out. – hadley Jul 03 '15 at 10:53
  • @StevieP were you able to figure this out ? we are trying to use RPostgres to connect to Amazon RDS and are having some trouble. any tips would be welcome. – Sandeep Jan 14 '16 at 10:06
  • @Sandeep: @hadley was correct, your DBA should be able to assist you. The use of `keepalives_*` is the way to go here. IIRC, I ended up dropping `keepalives` since the default is 1, and then set `keepalives_idle = 1` and `keepalives_idle = 10` (or something like that) since our DBA said he considered the traffic from the keep alive signal to be practically nothing in terms of usage costs. – StevieP Jan 15 '16 at 14:19

0 Answers0