pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Tignor <tptignor@yahoo.com>
To: Brad Nicholson <bradn@ca.ibm.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Cc: Vijaykumar Jain <vjain@opentable.com>
Subject: Re: [External] postgres 9.5 DB corruption: invalid byte sequence for encoding "UTF8"
Date: Tue, 26 Mar 2019 18:06:15 +0000 (UTC)
Message-ID: <1013768132.11403739.1553623575830@mail.yahoo.com> (raw)
In-Reply-To: <18058.1553609672@sss.pgh.pa.us>
References: <1080815989.10741938.1553539577631.ref@mail.yahoo.com>
	<1080815989.10741938.1553539577631@mail.yahoo.com>
	<CAE7uO5iDycP=aDVvxZgdfMCnd0Co1e2WQet_Y0wzWwp8bL1WAg@mail.gmail.com>
	<OF98369812.48E38ED5-ON852583C8.006CFB53-852583C8.006D7DA4@notes.na.collabserv.com>
	<458346306.10942574.1553559949857@mail.yahoo.com>
	<OFFA72AA86.7284C90C-ON852583C9.004C1102-852583C9.004CD75E@notes.na.collabserv.com>
	<18058.1553609672@sss.pgh.pa.us>

Hello again Brad, and hello Tom. Thanks for writing, and Tom I'll add some extra thanks for the many google searches over the years which have been answered by your posts. :)
It seems there's been some confusion on the data flow so I'll try to explain. The original "source" I referred to was our JVM generating alert data and performing DML on the DB via the v42.0.0 driver. I do not know of any encoding setting for the driver itself.
The driver writes directly to our primary (Slony-I master) DB. Changes are then replicated by our replica (Slony-I subscriber) DBs. Each of these DBs has a "UTF8" server encoding. COPY out ops (performed by Slony-I or anything else) always work fine, and COPY in ops fail if there is data corruption.

ams@ams3.dfw.netmgmt:/a/ams/lib/ext/database$ sum postgresql-42.0.0.jar 

12476   691

ams@ams3.dfw.netmgmt:/a/ams/lib/ext/database$ 

ams@ams3.dfw.netmgmt:~$ echo ---- Slony-I Master ----

---- Slony-I Master ----

ams@ams3.dfw.netmgmt:~$ psql -U akamai -d ams -c "SELECT datname, pg_encoding_to_char(encoding) FROM pg_database WHERE datname = 'ams'"

 datname | pg_encoding_to_char 

---------+---------------------

 ams     | UTF8

(1 row)




ams@ams3.dfw.netmgmt:~$ 

root@ams-repl7.sjc.netmgmt:~# echo ---- Slony-I Replica ----

---- Slony-I Replica ----

root@ams-repl7.sjc.netmgmt:~# psql -U akamai -d ams -c "SELECT datname, pg_encoding_to_char(encoding) FROM pg_database WHERE datname = 'ams'"

 datname | pg_encoding_to_char 

---------+---------------------

 ams     | UTF8

(1 row)




root@ams-repl7.sjc.netmgmt:~# 


Tom    :-) 

    On Tuesday, March 26, 2019, 10:14:59 AM EDT, Tom Lane <tgl@sss.pgh.pa.us> wrote:  
 
 "Brad Nicholson" <bradn@ca.ibm.com> writes:
> Thomas Tignor <tptignor@yahoo.com> wrote on 03/25/2019 08:25:49 PM:
>> Thanks for writing. As I mentioned to Vijay, the "source" is a JVM
>> using the postgres v42.0.0 JDBC driver. I do not believe we have any
>> explicit encoding set, and so I expect the client encoding is
>> SQL_ASCII. The DB is most definitely UTF8.

> These statements are contradictory.

> The value of client_encoding from your select on pg_settings is SQL_ASCII.

> The docs clearly state:
> https://www.postgresql.org/docs/9.5/runtime-config-client.html
> "Sets the client-side encoding (character set). The default is to use the
> database encoding. "

> If you don't have client_encoding explicitly, then it is using the database
> encoding.

Umm ... not necessarily.  That bit in runtime-config-client.html
correctly states what the *server's* default for client_encoding is,
but an awful lot of client-side code will immediately override that.
psql will try to set it based on its LANG/LC_CTYPE environment,
for example.  I don't know what JDBC does; it might be different.

But in any case, yes, it'd be more reliable to check pg_database.encoding
explicitly.

            regards, tom lane

  

view thread (10+ messages)

Message-ID: <1013768132.11403739.1553623575830@mail.yahoo.com>
Permalink:  ../1013768132.11403739.1553623575830@mail.yahoo.com/
Also on:    postgresql.org/message-id/1013768132.11403739.1553623575830@mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tptignor@yahoo.com, bradn@ca.ibm.com, tgl@sss.pgh.pa.us, vjain@opentable.com
  Subject: Re: [External] postgres 9.5 DB corruption: invalid byte sequence for encoding "UTF8"
  In-Reply-To: <1013768132.11403739.1553623575830@mail.yahoo.com>
  References: <1080815989.10741938.1553539577631.ref@mail.yahoo.com> <1080815989.10741938.1553539577631@mail.yahoo.com> <CAE7uO5iDycP=aDVvxZgdfMCnd0Co1e2WQet_Y0wzWwp8bL1WAg@mail.gmail.com> <OF98369812.48E38ED5-ON852583C8.006CFB53-852583C8.006D7DA4@notes.na.collabserv.com> <458346306.10942574.1553559949857@mail.yahoo.com> <OFFA72AA86.7284C90C-ON852583C9.004C1102-852583C9.004CD75E@notes.na.collabserv.com> <18058.1553609672@sss.pgh.pa.us> <1013768132.11403739.1553623575830@mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox