Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h8XMi-0006hu-A6 for pgsql-general@arkaria.postgresql.org; Mon, 25 Mar 2019 21:42:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h8XMg-0008Tr-5E for pgsql-general@arkaria.postgresql.org; Mon, 25 Mar 2019 21:42:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h8XMf-0008Tk-LW for pgsql-general@lists.postgresql.org; Mon, 25 Mar 2019 21:42:41 +0000 Received: from sonic301-3.consmr.mail.bf2.yahoo.com ([74.6.129.42]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h8XMW-00020G-HG for pgsql-general@lists.postgresql.org; Mon, 25 Mar 2019 21:42:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1553550150; bh=PXM4IDj3ihM+iZeJ/YdbqkNKCjSj0hb/UMFwD//mLgU=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From:Subject; b=nYfsns0NNXE4s6SMkCEkchowrIi3GKdyYQ8UfF0ETvNZntxDtsjASHwg8hYymWymuwYIvIF5R23GvGTwUL5roSDrPKwxPKaH+Ow9KgsnQFnGIbs5w5MlWQzA+56/rYeyNxF2Qmzv/02UEDyUG2PPGIJOCfjTWNhNGfgkTy8UNDDyNLFhAInu5vjn+qg0Y1DNmWmn+Zx1pTsPo8bctQKdkGeIeCJrjAyovc+0awtm61Y/pqKf8AAUh8G3ZJdj40uh1vu4RYpT6pd4Tzy4IBO0iT6a0pYbsH2Sw73QiziIK0AMRQkrUzES3IA9R156kCLXbwQa9hLTrVZZqhYMARScdQ== X-YMail-OSG: 9wsmtBIVM1ml07LPfo3lfwt.8S1Uf_9bw41P.zUbZK5e.S5Dx6s7tBUWkLOKd.0 AefSQtVOXPix5MUYlYIxP8haO0NvO6EuJ2zbxGGQ4VUNovIje60FQ.5PSKtyob3_uRnBCkXF.Pbb UId0SqsDYcQpWpYUUDd7AmyqfHtfWpwE68NTGLW.58e_Y5Mu5JNeSpBSGOUEsRkKNHc3ck.xjKvX KDQaevGvGV6PBOMjNXYziJ46BrAB8lZMioJYeKJg_y8BvsGKAEMoNlRo0LOqQjtHQng_c00Tghkl gjWkzeMACfatqwmtiIsdJFjVR0TykvJvGKip2eXHuXdZv_EeKsM3mmIBRxYAr7n_OGt3XdWhxJus VupJ2U4s64Wep_RndmwTSR8ueanpmOIDtARlN2.CovqjgNqFWPtFvBgvKG0rxFfV6OIzTnC_VsWN pQKpucS5Ru7ICvhRf8j6DlscCTr9Diy0U6VXlJG6O24v9mthfIoKBpZe_GEXFtjtF02ss0JZZ7bs NiRzO8zT122Rrt6o1ofsmxwVlm9qRN52PqmvVvpUmqFse4zQunEB72vLvvXcgMjUWVs8A2urWj_. SyjwLlDt50WPHv9KRLf_8hCMMuTKEU2G_Dhi7RgMJEOeZzR5uZUAmbDJ9LasTH2jSbsJoRLI0S4i K0beH.d66D9MHQB.ieDGc8VmpUCjP96bdOuOCsrXZFqW_PUNAbzZyPyFhJzbf9sX2uCAHXxtAaXF lWq0kkcSUUp6MSK419ezRsTy3.buoHi5VNOdGbo6zf_WvY3RCC9UF.xkGVBs6T.0zWvGfp_JWfxw GX7Uz0qHD4KlAb0TxFi_uxHwONRSt0vklSweaWkINsIU0_J0CpUMJHd9tpRj5IcDruAWFIiem6w3 ztSvxaeoqDg_prLXO3bSw9eCQgGVw5dXfhw24spdvmq6aEu9Egy7uFfDIDJL1FLQwI8aC6K9YpmB mQyghjzOOBnpkNu9X9ngvfO1tGd7CiGWlZ_WGnq5p3C_rmmAj8SIJbGIs6eGe8oG_ptZg.t4CRiP D8drQbVM5PvIt_JM0nxwlTDUCsGVlkJheCn_5NDox085E3lgSohi_eqWhlc89TFyrlXgzi3Qshs3 PLxhvsh81Mb4qFlGKusKTE3.ColAxC3Lt8V8zQE8O1GqlWhEJUqqAn_SIkoYkb8ck4NfMREOSpl7 Zt4D9YFD.kFYX9eAD_IZH14.v3KOZrFKi8j90nG8zVP2TQd2BI2K4hJyc Received: from sonic.gate.mail.ne1.yahoo.com by sonic301.consmr.mail.bf2.yahoo.com with HTTP; Mon, 25 Mar 2019 21:42:30 +0000 Date: Mon, 25 Mar 2019 21:42:25 +0000 (UTC) From: Thomas Tignor To: Vijaykumar Jain Cc: "pgsql-general@lists.postgresql.org" Message-ID: <769699225.10885828.1553550145380@mail.yahoo.com> In-Reply-To: References: <1080815989.10741938.1553539577631.ref@mail.yahoo.com> <1080815989.10741938.1553539577631@mail.yahoo.com> Subject: Re: [External] postgres 9.5 DB corruption: invalid byte sequence for encoding "UTF8" MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_10885827_828661820.1553550145371" X-Mailer: WebService/1.1.13212 YMailNorrin Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36 Content-Length: 56053 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_10885827_828661820.1553550145371 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Vijay,Thanks for writing. To your questions: =20 i think the experts will chime in soon, but why do you think this as db corruption and not just a bad input? https://github.com/postgres/postgres/blob/master/src/pl/plperl/expected/plp= erl_lc_1.out tptignor: Our JVM logs data before the insert and update ops. It all looks = fine there, and is usually straight ASCII.=C2=A0 or it may also be encoding issue. U137: Invalid byte sequence for encoding =C2=B7 pganalyze tptignor: There are a limited number of settings we apply to our driver, an= d the encoding isn't one of them. I expect it's using the server-configured= SQL_ASCII encoding, which I understand is like having no rules and just ta= kes data as is. can you do a pg_dump and restore on a parallel instance? does it result in failure? tptignor: We can do better than that. When this occurs, we isolate and COPY= the problem data to file (which always works fine), then COPY it back in. = (Without the COPY in ops, the corruption might even go unnoticed...) The er= ror on COPY in shows us a line number which takes us right to the corrupted= data. we also ask the app to log data (temporarily) inserted=C2=A0 so that we could figure out directly if there was bad data upstream or have validations to prevent inserts when there is bad data. also, in our case the query was stuck at "PARSE"=C2=A0 (if you do ps aux | grep postgres) and in some cases did result in oom. but upgrading the client and using session mode pooling in pgbouncer worked for us. tptignor: We depend on a JVM which works through the v42.0.0 postgres drive= r. We haven't taken a hard look yet at the driver, but certainly would if t= here was a reason. I would have expected the server to catch bad data on in= put from the driver in the same way it catches on COPY in. Tom=C2=A0 =C2=A0 :-) Regards, Vijay On Tue, Mar 26, 2019 at 12:17 AM Thomas Tignor wrote: > > Hoping someone may be able to offer some guidance on this recurring probl= em. I am providing this "problem report" to the general list as I understan= d the bugs list requires a set of reproduction steps we do not yet have. Pl= ease advise if I have the process wrong. I have tried to provide all known = relevant info here. Thanks in advance for any insights. > > --> A description of what you are trying to achieve and what results you = expect.: > > We are experiencing intermittent DB corruption in postgres 9.5.14. We are= trying to identify and eliminate all sources. We are using two independent= services for data replication, Slony-I v2.2.6 and a custom service develop= ed in-house. Both are based on COPY operations. DB corruption is observed w= hen COPY operations fail with an error of the form: 'invalid byte sequence = for encoding "UTF8"'. This occurs with a frequency ranging between a few da= ys and several weeks. Each incident is followed by a race to find and repai= r or remove corrupted data, which we are getting good at. With well over a = dozen incidents, the great majority originally showed corruption in a singl= e VARCHAR(2000) column (value) in a single table (alert_attribute). In this= time, we read about suspected and real problems with TOAST functionality a= nd so made the decision to change alert_attribute.value to PLAIN storage. S= ince that change was made, most new incidents show corruption in the alert_= attribute.name column instead (VARCHAR(200)). Another table (alert_instance= ) has been impacted as well. See below for their schemas. > > We have looked high and low through system logs and device reporting util= ity output for any sign of hardware failures. We haven't turned up anything= yet. We also tried rebuilding an entire DB from scratch. That did not seem= to help. > > We have not been performing routine reindexing. This is a problem we are = working to correct. Normally our master DB serves for an 8-12 week period w= ithout reindexing before we failover to a peer. Before assuming the master = role, the peer always begins by truncating the alert_instance and alert_att= ribute tables and loading all data from the current master. > > Hardware specs are listed below. For storage, we have 8 INTEL SSDSA2BW12 = direct-attached disks. We can provide additional info as needed. > > ams=3D# \d ams.alert_attribute >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Table "ams.alert_a= ttribute" >=C2=A0 =C2=A0 =C2=A0 Column=C2=A0 =C2=A0 =C2=A0 |=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 Type=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | Modifiers > -------------------+-------------------------+----------- >=C2=A0 alert_instance_id | integer=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 | not null >=C2=A0 name=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | character va= rying(200)=C2=A0 | not null >=C2=A0 data_type=C2=A0 =C2=A0 =C2=A0 =C2=A0 | smallint=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | not null >=C2=A0 value=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | character varying(= 2000) | > Indexes: >=C2=A0 =C2=A0 "pk_alert_attributes" PRIMARY KEY, btree (alert_instance_id,= name), tablespace "tbls5" >=C2=A0 =C2=A0 "idx_aa_aval" btree (name, value) > Foreign-key constraints: >=C2=A0 =C2=A0 "fk_alert_attr_instance_id" FOREIGN KEY (alert_instance_id) = REFERENCES ams.alert_instance(alert_instance_id) ON DELETE CASCADE > Triggers: >=C2=A0 =C2=A0 _ams_cluster_logtrigger AFTER INSERT OR DELETE OR UPDATE ON = ams.alert_attribute FOR EACH ROW EXECUTE PROCEDURE _ams_cluster.logtrigger(= '_ams_cluster', '2', 'kk') >=C2=A0 =C2=A0 _ams_cluster_truncatetrigger BEFORE TRUNCATE ON ams.alert_at= tribute FOR EACH STATEMENT EXECUTE PROCEDURE _ams_cluster.log_truncate('2') > Disabled user triggers: >=C2=A0 =C2=A0 _ams_cluster_denyaccess BEFORE INSERT OR DELETE OR UPDATE ON= ams.alert_attribute FOR EACH ROW EXECUTE PROCEDURE _ams_cluster.denyaccess= ('_ams_cluster') >=C2=A0 =C2=A0 _ams_cluster_truncatedeny BEFORE TRUNCATE ON ams.alert_attri= bute FOR EACH STATEMENT EXECUTE PROCEDURE _ams_cluster.deny_truncate() > > ams=3D# > ams=3D# \d ams.alert_instance >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Tabl= e "ams.alert_instance" >=C2=A0 =C2=A0 =C2=A0 =C2=A0 Column=C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Type=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 | Modifiers > ---------------------+--------------------------------+----------- >=C2=A0 alert_instance_id=C2=A0 | integer=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | not null >=C2=A0 alert_definition_id | integer=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | not null >=C2=A0 alert_instance_key=C2=A0 | character varying(500)=C2=A0 =C2=A0 =C2= =A0 =C2=A0 | not null >=C2=A0 start_active_date=C2=A0 | timestamp(0) without time zone | not null >=C2=A0 stop_active_date=C2=A0 =C2=A0 | timestamp(0) without time zone | >=C2=A0 active=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | smallint= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 | not null >=C2=A0 acknowledged=C2=A0 =C2=A0 =C2=A0 =C2=A0 | smallint=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | not null >=C2=A0 ack_clear_time=C2=A0 =C2=A0 =C2=A0 | timestamp(0) without time zone= | >=C2=A0 user_set_clear_time | smallint=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | >=C2=A0 category_id=C2=A0 =C2=A0 =C2=A0 =C2=A0 | integer=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | not nu= ll >=C2=A0 condition_start=C2=A0 =C2=A0 | timestamp(0) without time zone | not= null >=C2=A0 unack_reason=C2=A0 =C2=A0 =C2=A0 =C2=A0 | character varying(1)=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | >=C2=A0 viewer_visible=C2=A0 =C2=A0 =C2=A0 | smallint=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | not null > Indexes: >=C2=A0 =C2=A0 "pk_alert_instance" PRIMARY KEY, btree (alert_instance_id), = tablespace "tbls5" >=C2=A0 =C2=A0 "idx_alert_inst_1" btree (alert_instance_key, alert_definiti= on_id, alert_instance_id, active, acknowledged, ack_clear_time), tablespace= "tbls5" >=C2=A0 =C2=A0 "idx_alert_inst_cat_id" btree (category_id), tablespace "tbl= s5" >=C2=A0 =C2=A0 "idx_alert_inst_def_id" btree (alert_definition_id), tablesp= ace "tbls5" > Check constraints: >=C2=A0 =C2=A0 "ck_alert_inst_acked" CHECK (acknowledged =3D 0 OR acknowled= ged =3D 1) >=C2=A0 =C2=A0 "ck_alert_inst_active" CHECK (active =3D 0 OR active =3D 1) >=C2=A0 =C2=A0 "ck_alert_inst_set_cl_tm" CHECK (user_set_clear_time =3D 0 O= R user_set_clear_time =3D 1) >=C2=A0 =C2=A0 "ck_alert_inst_viewer_vis" CHECK (viewer_visible =3D 0 OR vi= ewer_visible =3D 1) > Foreign-key constraints: >=C2=A0 =C2=A0 "fk_alert_inst_cat_id" FOREIGN KEY (category_id) REFERENCES = ams.category(category_id) >=C2=A0 =C2=A0 "fk_alert_inst_def_id" FOREIGN KEY (alert_definition_id) REF= ERENCES ams.alert_definition(alert_definition_id) >=C2=A0 =C2=A0 "fk_alert_inst_unack_reason" FOREIGN KEY (unack_reason) REFE= RENCES ams.unack_reason(unack_reason) > Referenced by: >=C2=A0 =C2=A0 TABLE "ams.alert_attribute" CONSTRAINT "fk_alert_attr_instan= ce_id" FOREIGN KEY (alert_instance_id) REFERENCES ams.alert_instance(alert_= instance_id) ON DELETE CASCADE > Triggers: >=C2=A0 =C2=A0 _ams_cluster_logtrigger AFTER INSERT OR DELETE OR UPDATE ON = ams.alert_instance FOR EACH ROW EXECUTE PROCEDURE _ams_cluster.logtrigger('= _ams_cluster', '1', 'k') >=C2=A0 =C2=A0 _ams_cluster_truncatetrigger BEFORE TRUNCATE ON ams.alert_in= stance FOR EACH STATEMENT EXECUTE PROCEDURE _ams_cluster.log_truncate('1') > Disabled user triggers: >=C2=A0 =C2=A0 _ams_cluster_denyaccess BEFORE INSERT OR DELETE OR UPDATE ON= ams.alert_instance FOR EACH ROW EXECUTE PROCEDURE _ams_cluster.denyaccess(= '_ams_cluster') >=C2=A0 =C2=A0 _ams_cluster_truncatedeny BEFORE TRUNCATE ON ams.alert_insta= nce FOR EACH STATEMENT EXECUTE PROCEDURE _ams_cluster.deny_truncate() > > ams=3D# > > --> PostgreSQL version number you are running: > 9.5.14 > > --> How you installed PostgreSQL: > We use a customized installer. It copies a =E2=80=9Cmake install=E2=80=9D= -based distribution into place on a target install host. > Our compiler is gcc 5.4.0. > > CFLAGS: -m32 -march=3Dopteron -mno-3dnow -ggdb -O2 -Wall > > $P/CONFIGURE_OPTIONS :=3D \ >=C2=A0 =C2=A0 =C2=A0 =C2=A0 --with-perl \ >=C2=A0 =C2=A0 =C2=A0 =C2=A0 --with-openssl \ >=C2=A0 =C2=A0 =C2=A0 =C2=A0 --with-libxml \ >=C2=A0 =C2=A0 =C2=A0 =C2=A0 --with-libxslt \ >=C2=A0 =C2=A0 =C2=A0 =C2=A0 --with-includes=3D"$(COMMON)/include/perl $(CO= MMON)/include" \ >=C2=A0 =C2=A0 =C2=A0 =C2=A0 --with-libs=3D"$(COMMON)/lib" --prefix=3D$($P/= PREFIX) \ >=C2=A0 =C2=A0 =C2=A0 =C2=A0 --enable-debug \ >=C2=A0 =C2=A0 =C2=A0 =C2=A0 --disable-nls > > --> Changes made to the settings in the postgresql.conf file:=C2=A0 see S= erver Configuration for a quick way to list them all. > ams=3D# SELECT version(); >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 version > -------------------------------------------------------------------------= ----------------------------------------------- >=C2=A0 PostgreSQL 9.5.14 on i686-pc-linux-gnu, compiled by gcc (Ubuntu 5.4= .0-6ubuntu1~16.04.9aka9.0.3) 5.4.0 20160609, 32-bit > (1 row) > > ams=3D# SELECT name, current_setting(name), SOURCE > ams-#=C2=A0 FROM pg_settings > ams-#=C2=A0 WHERE SOURCE NOT IN ('default', 'override'); >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 name=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 current_setting=C2=A0 |=C2=A0 =C2=A0 = =C2=A0 =C2=A0 source > --------------------------------+--------------------+-------------------= --- >=C2=A0 application_name=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | = psql=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | client >=C2=A0 autovacuum_vacuum_cost_delay=C2=A0 | 100ms=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 | configuration file >=C2=A0 checkpoint_completion_target=C2=A0 | 0.9=C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configuration file >=C2=A0 client_encoding=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 | SQL_ASCII=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | client >=C2=A0 cpu_index_tuple_cost=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 0.001=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configuration file >=C2=A0 cpu_operator_cost=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |= 0.0005=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configuration file >=C2=A0 cpu_tuple_cost=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 | 0.002=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configuration= file >=C2=A0 DateStyle=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 | ISO, MDY=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configu= ration file >=C2=A0 default_statistics_target=C2=A0 =C2=A0 =C2=A0 | 150=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configuration file >=C2=A0 default_text_search_config=C2=A0 =C2=A0 | pg_catalog.english | conf= iguration file >=C2=A0 effective_cache_size=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 8007MB=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configuration file >=C2=A0 lc_messages=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 | C=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 | configuration file >=C2=A0 lc_monetary=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 | C=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 | configuration file >=C2=A0 lc_numeric=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 | C=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 | configuration file >=C2=A0 lc_time=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 | C=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 | configuration file >=C2=A0 listen_addresses=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | = 0.0.0.0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configuration file >=C2=A0 log_autovacuum_min_duration=C2=A0 =C2=A0 | 0=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configuration file >=C2=A0 log_checkpoints=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 | on=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configura= tion file >=C2=A0 log_connections=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 | on=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configura= tion file >=C2=A0 log_disconnections=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | on=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configuration file >=C2=A0 log_line_prefix=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 | %m %p %u %h %d=C2=A0 =C2=A0 | configuration file >=C2=A0 log_min_duration_statement=C2=A0 =C2=A0 | 1min=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configuration file >=C2=A0 log_min_messages=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | = notice=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configuration file >=C2=A0 log_temp_files=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 | 0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | con= figuration file >=C2=A0 maintenance_work_mem=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 512MB=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configuration file >=C2=A0 max_connections=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 | 600=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configur= ation file >=C2=A0 max_stack_depth=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 | 2MB=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | environm= ent variable >=C2=A0 max_wal_size=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 | 15360TB=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configuration = file >=C2=A0 random_page_cost=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | = 2.5=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configuration = file >=C2=A0 restart_after_crash=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | off= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configuration fil= e >=C2=A0 shared_buffers=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 | 2GB=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configur= ation file >=C2=A0 ssl=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | on=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 | configuration file >=C2=A0 ssl_ca_file=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 | root.crt=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configuration = file >=C2=A0 standard_conforming_strings=C2=A0 =C2=A0 | on=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configuration file >=C2=A0 statement_timeout=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |= 1min=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configuration file >=C2=A0 superuser_reserved_connections | 10=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 | configuration file >=C2=A0 syslog_ident=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 | postgresql9.5-1.12 | configuration file >=C2=A0 tcp_keepalives_idle=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 0=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configuration= file >=C2=A0 unix_socket_permissions=C2=A0 =C2=A0 =C2=A0 =C2=A0 | 0770=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | configuration file >=C2=A0 work_mem=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 | 30MB=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | = configuration file > (40 rows) > > ams=3D# > > --> Operating system and version: > Ubuntu 16.04.5 LTS > > --> What program you're using to connect to PostgreSQL: > Most DML is performed by a standalone JVM using the PostgreSQL JDBC Drive= r v42.0.0. > > --> Is there anything relevant or unusual in the PostgreSQL server logs?: > We have sometimes but not always seen "invalid memory alloc request size"= errors around the time of these events. Our experience suggests that "inva= lid memory alloc request size" errors are a symptom specifically of index c= orruption and are remediated by reindexing. > > --> For questions about any kind of error: > --> What you were doing when the error happened / how to cause the error: > Periodic DML (inserts and updates) focused primarily on two DB tables (am= s.alert_instance and ams.alert_attribute) with hourly batched transfers of = inactive alerts to history tables (deletes from ams.alert_instance, ams.ale= rt_attribute and corresponding inserts to ams.alert_instance_hist, ams.aler= t_attribute_hist within the same transaction). > > --> The EXACT TEXT of the error message you're getting, if there is one: = (Copy and paste the message to the email, do not send a screenshot) > 2018-12-27 07:25:24.527 GMT 30462 appuser 127.0.0.1 ams ERROR:=C2=A0 inva= lid byte sequence for encoding "UTF8": 0x86 > The specific identified byte varies with each incident. > > --> CPU Info > 2*4-core Intel(R) Xeon(R) CPU E31270 @ 3.40GHz > > --> Mem Info > 16GB RAM > > --> Storage Info > root@ams4.dfw.netmgmt:~# lsscsi -l > > [0:0:0:0]=C2=A0 =C2=A0 disk=C2=A0 =C2=A0 ATA=C2=A0 =C2=A0 =C2=A0 INTEL SS= DSA2BW12 0362=C2=A0 /dev/sda >=C2=A0 state=3Drunning queue_depth=3D32 scsi_level=3D7 type=3D0 device_blo= cked=3D0 timeout=3D30 > [0:0:1:0]=C2=A0 =C2=A0 disk=C2=A0 =C2=A0 ATA=C2=A0 =C2=A0 =C2=A0 INTEL SS= DSA2BW12 0362=C2=A0 /dev/sdb >=C2=A0 state=3Drunning queue_depth=3D32 scsi_level=3D7 type=3D0 device_blo= cked=3D0 timeout=3D30 > [0:0:2:0]=C2=A0 =C2=A0 disk=C2=A0 =C2=A0 ATA=C2=A0 =C2=A0 =C2=A0 INTEL SS= DSA2BW12 0362=C2=A0 /dev/sdc >=C2=A0 state=3Drunning queue_depth=3D32 scsi_level=3D7 type=3D0 device_blo= cked=3D0 timeout=3D30 > [0:0:3:0]=C2=A0 =C2=A0 disk=C2=A0 =C2=A0 ATA=C2=A0 =C2=A0 =C2=A0 INTEL SS= DSA2BW12 0362=C2=A0 /dev/sdd >=C2=A0 state=3Drunning queue_depth=3D32 scsi_level=3D7 type=3D0 device_blo= cked=3D0 timeout=3D30 > [0:0:4:0]=C2=A0 =C2=A0 disk=C2=A0 =C2=A0 ATA=C2=A0 =C2=A0 =C2=A0 INTEL SS= DSA2BW12 0362=C2=A0 /dev/sde >=C2=A0 state=3Drunning queue_depth=3D32 scsi_level=3D7 type=3D0 device_blo= cked=3D0 timeout=3D30 > [0:0:5:0]=C2=A0 =C2=A0 disk=C2=A0 =C2=A0 ATA=C2=A0 =C2=A0 =C2=A0 INTEL SS= DSA2BW12 0362=C2=A0 /dev/sdf >=C2=A0 state=3Drunning queue_depth=3D32 scsi_level=3D7 type=3D0 device_blo= cked=3D0 timeout=3D30 > [0:0:6:0]=C2=A0 =C2=A0 disk=C2=A0 =C2=A0 ATA=C2=A0 =C2=A0 =C2=A0 INTEL SS= DSA2BW12 0362=C2=A0 /dev/sdg >=C2=A0 state=3Drunning queue_depth=3D32 scsi_level=3D7 type=3D0 device_blo= cked=3D0 timeout=3D30 > [0:0:7:0]=C2=A0 =C2=A0 disk=C2=A0 =C2=A0 ATA=C2=A0 =C2=A0 =C2=A0 INTEL SS= DSA2BW12 0362=C2=A0 /dev/sdh >=C2=A0 state=3Drunning queue_depth=3D32 scsi_level=3D7 type=3D0 device_blo= cked=3D0 timeout=3D30 > root@ams4.dfw.netmgmt:~# > > root@ams4.dfw.netmgmt:~# modinfo md_mod > filename:=C2=A0 =C2=A0 =C2=A0 /lib/modules/4.14.68-4.14.3-amd64-3adf36756= 65129fa/kernel/drivers/md/md-mod.ko > alias:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 block-major-9-* > alias:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 md > description:=C2=A0 =C2=A0 MD RAID framework > license:=C2=A0 =C2=A0 =C2=A0 =C2=A0 GPL > depends: > retpoline:=C2=A0 =C2=A0 =C2=A0 Y > intree:=C2=A0 =C2=A0 =C2=A0 =C2=A0 Y > name:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 md_mod > vermagic:=C2=A0 =C2=A0 =C2=A0 4.14.68-4.14.3-amd64-3adf3675665129fa SMP m= od_unload modversions > parm:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 start_dirty_degraded:int > parm:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 create_on_open:bool > root@ams4.dfw.netmgmt:~# > > > Tom=C2=A0 =C2=A0 :-) |=20 |=20 | |=20 U137: Invalid byte sequence for encoding =C2=B7 pganalyze DBAs and developers use pganalyze to identify the root cause of performance= issues, optimize queries and to get ... | | | =20 ------=_Part_10885827_828661820.1553550145371 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi Vijay,
Thanks for writing. To your questions:

<= /div>
i think the experts will chime in soon,

but why do you think this as db corruption and= not just a bad input?
https://github.com/postgres/postgres/b= lob/master/src/pl/plperl/expected/plperl_lc_1.out


tptignor: Our JVM = logs data before the insert and update ops. It all looks fine there, and is= usually straight ASCII. 

tptignor: Th= ere are a limited number of settings we apply to our driver, and the encodi= ng isn't one of them. I expect it's using the server-configured SQL_ASCII e= ncoding, which I understand is like having no rules and just takes data as = is.


can = you do a pg_dump and restore on a parallel instance? does it<= br clear=3D"none">= result in failure?

tptignor: We can do bett= er than that. When this occurs, we isolate and COPY the problem data to fil= e (which always works fine), then COPY it back in. (Without the COPY in ops= , the corruption might even go unnoticed...) The error on COPY in shows us = a line number which takes us right to the corrupted data.


we also ask= the app to log data (temporarily) inserted  so that we<= br clear=3D"none">= could figure out directly if there was bad data upstream or have
validations to prevent inserts when there is bad data.
also, in our case the query was stuck at "PARSE"  (if= you do ps aux |
grep postgres) and in some cases did result = in oom.
but upgrading the client and using session mode pooli= ng in pgbouncer
worked for us.

tptignor: = We depend on a JVM which works through the v42.0.0 postgres driver. We have= n't taken a hard look yet at the driver, but certainly would if there was a= reason. I would have expected the server to catch bad data on input from t= he driver in the same way it catches on COPY in.

Tom   = :-)


Regards,
Vijay
=
On Tue, Mar 26, 2019 at 12:17 AM Thomas Tignor <tptignor@yahoo.com> wrote:
>
> Hoping someone may be able to offer some guidance on this re= curring problem. I am providing this "problem report" to the general list a= s I understand the bugs list requires a set of reproduction steps we do not= yet have. Please advise if I have the process wrong. I have tried to provi= de all known relevant info here. Thanks in advance for any insights.
>
> --> A description of what you ar= e trying to achieve and what results you expect.:
>> We are experiencing intermittent DB corruption in post= gres 9.5.14. We are trying to identify and eliminate all sources. We are us= ing two independent services for data replication, Slony-I v2.2.6 and a cus= tom service developed in-house. Both are based on COPY operations. DB corru= ption is observed when COPY operations fail with an error of the form: 'inv= alid byte sequence for encoding "UTF8"'. This occurs with a frequency rangi= ng between a few days and several weeks. Each incident is followed by a rac= e to find and repair or remove corrupted data, which we are getting good at= . With well over a dozen incidents, the great majority originally showed co= rruption in a single VARCHAR(2000) column (value) in a single table (alert_= attribute). In this time, we read about suspected and real problems with TO= AST functionality and so made the decision to change alert_attribute.value = to PLAIN storage. Since that change was made, most new incidents show corru= ption in the alert_attribute.name column instead (VARCHAR(200)). Another ta= ble (alert_instance) has been impacted as well. See below for their schemas= .
>
> We have looked high and low= through system logs and device reporting utility output for any sign of ha= rdware failures. We haven't turned up anything yet. We also tried rebuildin= g an entire DB from scratch. That did not seem to help.
&= gt;
> We have not been performing routine reindexing. = This is a problem we are working to correct. Normally our master DB serves = for an 8-12 week period without reindexing before we failover to a peer. Be= fore assuming the master role, the peer always begins by truncating the ale= rt_instance and alert_attribute tables and loading all data from the curren= t master.
>
> Hardware specs are = listed below. For storage, we have 8 INTEL SSDSA2BW12 direct-attached disks= . We can provide additional info as needed.
>
> ams=3D# \d ams.alert_attribute
>  =               Table "ams.alert_attribute= "
>      Column      |=           Type          = | Modifiers
> -------------------+--------------------= -----+-----------
>  alert_instance_id | integer&= nbsp;               | not null
>  name              |= character varying(200)  | not null
>  data_= type        | smallint        &nbs= p;       | not null
>  value =           | character varying(2000) |
> Indexes:
>    "pk_alert_attr= ibutes" PRIMARY KEY, btree (alert_instance_id, name), tablespace "tbls5">    "idx_aa_aval" btree (name, value)
> Foreign-key constraints:
>  &nbs= p; "fk_alert_attr_instance_id" FOREIGN KEY (alert_instance_id) REFERENCES = ams.alert_instance(alert_instance_id) ON DELETE CASCADE
&= gt; Triggers:
>    _ams_cluster_logtrigger = AFTER INSERT OR DELETE OR UPDATE ON ams.alert_attribute FOR EACH ROW EXECUT= E PROCEDURE _ams_cluster.logtrigger('_ams_cluster', '2', 'kk')
>    _ams_cluster_truncatetrigger BEFORE TRUNCATE ON am= s.alert_attribute FOR EACH STATEMENT EXECUTE PROCEDURE _ams_cluster.log_tru= ncate('2')
> Disabled user triggers:
>    _ams_cluster_denyaccess BEFORE INSERT OR DELETE OR UPDA= TE ON ams.alert_attribute FOR EACH ROW EXECUTE PROCEDURE _ams_cluster.denya= ccess('_ams_cluster')
>    _ams_cluster_tru= ncatedeny BEFORE TRUNCATE ON ams.alert_attribute FOR EACH STATEMENT EXECUTE= PROCEDURE _ams_cluster.deny_truncate()
>
> ams=3D#
> ams=3D# \d ams.alert_instance
>                =     Table "ams.alert_instance"
>  &nbs= p;     Column        |      &n= bsp;       Type            &nb= sp; | Modifiers
> ---------------------+--------------= ------------------+-----------
>  alert_instance_= id  | integer                =         | not null
>  alert_d= efinition_id | integer              &nbs= p;         | not null
>  aler= t_instance_key  | character varying(500)        |= not null
>  start_active_date  | timestamp= (0) without time zone | not null
>  stop_active_d= ate    | timestamp(0) without time zone |
>&= nbsp; active              | smallint&nbs= p;                     |= not null
>  acknowledged      &nb= sp; | smallint                 = ;     | not null
>  ack_clear_time&nbs= p;     | timestamp(0) without time zone |
>&= nbsp; user_set_clear_time | smallint          &nbs= p;           |
>  categ= ory_id        | integer        &nb= sp;               | not null
>  condition_start    | timestamp(0) without time= zone | not null
>  unack_reason    &nb= sp;   | character varying(1)          |
>  viewer_visible      | smallint = ;                     | = not null
> Indexes:
>   = ; "pk_alert_instance" PRIMARY KEY, btree (alert_instance_id), tablespace "= tbls5"
>    "idx_alert_inst_1" btree (alert= _instance_key, alert_definition_id, alert_instance_id, active, acknowledged= , ack_clear_time), tablespace "tbls5"
>    = "idx_alert_inst_cat_id" btree (category_id), tablespace "tbls5"
>    "idx_alert_inst_def_id" btree (alert_definition_i= d), tablespace "tbls5"
> Check constraints:
>    "ck_alert_inst_acked" CHECK (acknowledged =3D = 0 OR acknowledged =3D 1)
>    "ck_alert_ins= t_active" CHECK (active =3D 0 OR active =3D 1)
> =   "ck_alert_inst_set_cl_tm" CHECK (user_set_clear_time =3D 0 OR user= _set_clear_time =3D 1)
>    "ck_alert_inst_= viewer_vis" CHECK (viewer_visible =3D 0 OR viewer_visible =3D 1)
> Foreign-key constraints:
>   = "fk_alert_inst_cat_id" FOREIGN KEY (category_id) REFERENCES ams.category(= category_id)
>    "fk_alert_inst_def_id" FO= REIGN KEY (alert_definition_id) REFERENCES ams.alert_definition(alert_defin= ition_id)
>    "fk_alert_inst_unack_reason"= FOREIGN KEY (unack_reason) REFERENCES ams.unack_reason(unack_reason)
> Referenced by:
>    TABLE= "ams.alert_attribute" CONSTRAINT "fk_alert_attr_instance_id" FOREIGN KEY (= alert_instance_id) REFERENCES ams.alert_instance(alert_instance_id) ON DELE= TE CASCADE
> Triggers:
>  &n= bsp; _ams_cluster_logtrigger AFTER INSERT OR DELETE OR UPDATE ON ams.alert= _instance FOR EACH ROW EXECUTE PROCEDURE _ams_cluster.logtrigger('_ams_clus= ter', '1', 'k')
>    _ams_cluster_truncatet= rigger BEFORE TRUNCATE ON ams.alert_instance FOR EACH STATEMENT EXECUTE PRO= CEDURE _ams_cluster.log_truncate('1')
> Disabled user = triggers:
>    _ams_cluster_denyaccess BEFO= RE INSERT OR DELETE OR UPDATE ON ams.alert_instance FOR EACH ROW EXECUTE PR= OCEDURE _ams_cluster.denyaccess('_ams_cluster')
> = ;   _ams_cluster_truncatedeny BEFORE TRUNCATE ON ams.alert_instance F= OR EACH STATEMENT EXECUTE PROCEDURE _ams_cluster.deny_truncate()
>
> ams=3D#
>
> --> PostgreSQL version number you are running:
> 9.5.14
>
> --> = How you installed PostgreSQL:
> We use a customized in= staller. It copies a =E2=80=9Cmake install=E2=80=9D-based distribution into= place on a target install host.
> Our compiler is gcc= 5.4.0.
>
> CFLAGS: -m32 -march= =3Dopteron -mno-3dnow -ggdb -O2 -Wall
>
> $P/CONFIGURE_OPTIONS :=3D \
>    &n= bsp;   --with-perl \
>       = ; --with-openssl \
>        --wi= th-libxml \
>        --with-libxs= lt \
>        --with-includes=3D"= $(COMMON)/include/perl $(COMMON)/include" \
>  &n= bsp;     --with-libs=3D"$(COMMON)/lib" --prefix=3D$($P/PREFIX) \=
>        --enable-debug \
>        --disable-nls
>
> --> Changes made to the settings in the po= stgresql.conf file:  see Server Configuration for a quick way to list = them all.
> ams=3D# SELECT version();
>                   =                     &nbs= p;               version
> ------------------------------------------------------------------= ------------------------------------------------------
&g= t;  PostgreSQL 9.5.14 on i686-pc-linux-gnu, compiled by gcc (Ubuntu 5.= 4.0-6ubuntu1~16.04.9aka9.0.3) 5.4.0 20160609, 32-bit
>= (1 row)
>
> ams=3D# SELECT name,= current_setting(name), SOURCE
> ams-#  FROM pg_= settings
> ams-#  WHERE SOURCE NOT IN ('default'= , 'override');
>          &nb= sp;   name              |  cu= rrent_setting  |        source
= > --------------------------------+--------------------+----------------= ------
>  application_name      &n= bsp;       | psql            =   | client
>  autovacuum_vacuum_cost_delay&= nbsp; | 100ms              | configurat= ion file
>  checkpoint_completion_target  |= 0.9                | configuration= file
>  client_encoding      &nbs= p;         | SQL_ASCII         = ; | client
>  cpu_index_tuple_cost    &= nbsp;     | 0.001             = ; | configuration file
>  cpu_operator_cost =             | 0.0005      &nb= sp;     | configuration file
>  cpu_tu= ple_cost                | 0.002&nb= sp;             | configuration file
>  DateStyle            &nb= sp;         | ISO, MDY         = ; | configuration file
>  default_statistics_tar= get      | 150            &nbs= p;   | configuration file
>  default_text_se= arch_config    | pg_catalog.english | configuration file
>  effective_cache_size         = ; | 8007MB            | configuration file<= br clear=3D"none">>  lc_messages          =           | C          &n= bsp;       | configuration file
> = lc_monetary                  =   | C                  | = configuration file
>  lc_numeric    &nb= sp;               | C    &nbs= p;             | configuration file
>  lc_time             = ;           | C          =         | configuration file
>&nbs= p; listen_addresses              | 0.0.= 0.0            | configuration file
>  log_autovacuum_min_duration    | 0  &nb= sp;               | configuration file>  log_checkpoints        &nbs= p;       | on             = ;   | configuration file
>  log_connections=                 | on    &= nbsp;           | configuration file
>  log_disconnections           = ; | on                | configura= tion file
>  log_line_prefix      =           | %m %p %u %h %d    | configu= ration file
>  log_min_duration_statement  &= nbsp; | 1min              | configurat= ion file
>  log_min_messages      =         | notice          &nb= sp; | configuration file
>  log_temp_files =               | 0      =             | configuration file
>  maintenance_work_mem          | = 512MB              | configuration file<= br clear=3D"none">>  max_connections        &nb= sp;       | 600            &nb= sp;   | configuration file
>  max_stack_dept= h                | 2MB   =             | environment variable
>  max_wal_size            =       | 15360TB            | = configuration file
>  random_page_cost  &nbs= p;           | 2.5        &nb= sp;       | configuration file
>  = restart_after_crash            | off  &n= bsp;             | configuration file
>  shared_buffers          &nbs= p;     | 2GB              &nb= sp; | configuration file
>  ssl    &nbs= p;                     &n= bsp; | on                | configu= ration file
>  ssl_ca_file      &n= bsp;             | root.crt    &nbs= p;     | configuration file
>  standar= d_conforming_strings    | on          &n= bsp;     | configuration file
>  state= ment_timeout              | 1min  &= nbsp;           | configuration file
>  superuser_reserved_connections | 10      &n= bsp;         | configuration file
&g= t;  syslog_ident               = ;   | postgresql9.5-1.12 | configuration file
>&= nbsp; tcp_keepalives_idle            | 0 = ;                 | configuration f= ile
>  unix_socket_permissions     = ;   | 0770              | configur= ation file
>  work_mem       =               | 30MB    &nbs= p;         | configuration file
>= (40 rows)
>
> ams=3D#
>
> --> Operating system and version:<= br clear=3D"none">> Ubuntu 16.04.5 LTS
>
> --> What program you're using to connect to PostgreSQL:> Most DML is performed by a standalone JVM using the P= ostgreSQL JDBC Driver v42.0.0.
>
>= ; --> Is there anything relevant or unusual in the PostgreSQL server log= s?:
> We have sometimes but not always seen "invalid m= emory alloc request size" errors around the time of these events. Our exper= ience suggests that "invalid memory alloc request size" errors are a sympto= m specifically of index corruption and are remediated by reindexing.
>
> --> For questions about any kind= of error:
> --> What you were doing when the error= happened / how to cause the error:
> Periodic DML (in= serts and updates) focused primarily on two DB tables (ams.alert_instance a= nd ams.alert_attribute) with hourly batched transfers of inactive alerts to= history tables (deletes from ams.alert_instance, ams.alert_attribute and c= orresponding inserts to ams.alert_instance_hist, ams.alert_attribute_hist w= ithin the same transaction).
>
> = --> The EXACT TEXT of the error message you're getting, if there is one:= (Copy and paste the message to the email, do not send a screenshot)
> 2018-12-27 07:25:24.527 GMT 30462 appuser 127.0.0.1 ams ER= ROR:  invalid byte sequence for encoding "UTF8": 0x86
> The specific identified byte varies with each incident.
>
> --> CPU Info
> 2*= 4-core Intel(R) Xeon(R) CPU E31270 @ 3.40GHz
>
> --> Mem Info
> 16GB RAM
>
> --> Storage Info
&g= t; root@ams4.dfw.netmgmt:~# lsscsi -l
>
> [0:0:0:0]    disk    ATA&n= bsp;     INTEL SSDSA2BW12 0362  /dev/sda
&= gt;  state=3Drunning queue_depth=3D32 scsi_level=3D7 type=3D0 device_= blocked=3D0 timeout=3D30
> [0:0:1:0]    disk=     ATA      INTEL SSDSA2BW12 0362  /dev/sdb<= br clear=3D"none">>  state=3Drunning queue_depth=3D32 scsi_level= =3D7 type=3D0 device_blocked=3D0 timeout=3D30
> [0:0:2= :0]    disk    ATA      INTEL SSDSA2BW12= 0362  /dev/sdc
>  state=3Drunning queue_de= pth=3D32 scsi_level=3D7 type=3D0 device_blocked=3D0 timeout=3D30
> [0:0:3:0]    disk    ATA    &n= bsp; INTEL SSDSA2BW12 0362  /dev/sdd
>  sta= te=3Drunning queue_depth=3D32 scsi_level=3D7 type=3D0 device_blocked=3D0 ti= meout=3D30
> [0:0:4:0]    disk    = ATA      INTEL SSDSA2BW12 0362  /dev/sde
>  state=3Drunning queue_depth=3D32 scsi_level=3D7 type=3D0 de= vice_blocked=3D0 timeout=3D30
> [0:0:5:0]   = disk    ATA      INTEL SSDSA2BW12 0362  /dev= /sdf
>  state=3Drunning queue_depth=3D32 scsi_le= vel=3D7 type=3D0 device_blocked=3D0 timeout=3D30
> [0:= 0:6:0]    disk    ATA      INTEL SSDSA2B= W12 0362  /dev/sdg
>  state=3Drunning queue= _depth=3D32 scsi_level=3D7 type=3D0 device_blocked=3D0 timeout=3D30
> [0:0:7:0]    disk    ATA    &= nbsp; INTEL SSDSA2BW12 0362  /dev/sdh
>  st= ate=3Drunning queue_depth=3D32 scsi_level=3D7 type=3D0 device_blocked=3D0 t= imeout=3D30
> root@ams4.dfw.netmgmt:~#
>
>
root@a= ms4.dfw.netmgmt:~# modinfo md_mod
> filename: = ;     /lib/modules/4.14.68-4.14.3-amd64-3adf3675665129fa/kernel/= drivers/md/md-mod.ko
> alias:      &nbs= p;   block-major-9-*
> alias:     =     md
> description:    MD RAID = framework
> license:        GPL> depends:
> retpoline:   = ;   Y
> intree:        Y
> name:          md_mod
> vermagic:      4.14.68-4.14.3-amd64-3adf367= 5665129fa SMP mod_unload modversions
> parm:  &nb= sp;       start_dirty_degraded:int
> p= arm:          create_on_open:bool
> root@ams4.dfw.netmgmt:~#
>=
>
> Tom    :-)