Re: jdbc targetServerType=slave with readonly connection

From: Vladimir Sitnikov <sitnikov(dot)vladimir(at)gmail(dot)com>
To: Vladimír Houba ml(dot) <vladojr(at)prosoft(dot)sk>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: jdbc targetServerType=slave with readonly connection
Date: 2018-01-16 17:38:50
Message-ID: CAB=Je-HXDJJtvGNz4Kj0XE=-j2yP+iwp1y789tAerbVRd1bQBQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-jdbc

>the slave replication server does not seem to be recognized correctly

Could you elaborate on what do you mean by "does not seem to be recognized
correctly"?

You might be hitting https://github.com/pgjdbc/pgjdbc/pull/844 , so would
you please check if pgjdbc 42.2.0-SNAPSHOT (e.g.
https://oss.sonatype.org/content/repositories/snapshots/org/postgresql/postgresql/42.2.0-SNAPSHOT/
)
resolves your issue?

>jdbc driver thinks it is connected to a slave

pjgdbc uses "show transaction_read_only" query to tell master from
secondary.

"readOnly=true" connection option is used/activated _after_ the connection,
so it should not impact master/secondary selection.

PS. There's 10 second-long (hostRecheckSeconds) cache of the host status.
That is, pgjdbc caches master/secondary state of the host for 10 seconds by
default, so it might "fail" to identify recently activated secondary.

Vladimir

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2018-01-16 19:23:28 Re: proposal: alternative psql commands quit and exit
Previous Message Tom Lane 2018-01-16 17:31:18 Re: proposal: alternative psql commands quit and exit

Browse pgsql-jdbc by date

  From Date Subject
Next Message vlsi 2018-01-17 05:36:49 [pgjdbc/pgjdbc]
Previous Message Dave Cramer 2018-01-16 17:10:25 [pgjdbc/pgjdbc] 71b3c1: test: add "as" to test queries so they work with P...