Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eWuU3-0000kS-AF for pgsql-admin@arkaria.postgresql.org; Thu, 04 Jan 2018 01:38:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eWuU2-0004B2-ER for pgsql-admin@arkaria.postgresql.org; Thu, 04 Jan 2018 01:38:14 +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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eWuU2-0004At-7S for pgsql-admin@lists.postgresql.org; Thu, 04 Jan 2018 01:38:14 +0000 Received: from cat-porwal-prod-mail1.catalyst.net.nz ([2404:130:4080::4]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eWuTu-0005c1-PK for pgsql-admin@lists.postgresql.org; Thu, 04 Jan 2018 01:38:11 +0000 Received: from [IPv6:2406:e001:f09:1:cd61:bcc0:75b8:894f] (unknown [IPv6:2406:e001:f09:1:cd61:bcc0:75b8:894f]) (Authenticated sender: mark.kirkwood@catalyst.net.nz) by cat-porwal-prod-mail1.catalyst.net.nz (Postfix) with ESMTPSA id A1E47806F6 for ; Thu, 4 Jan 2018 14:37:55 +1300 (NZDT) Subject: Re: pt_toast table seems to be To: pgsql-admin@lists.postgresql.org References: <79C6454F-E7F3-4AB9-A329-BECB41835BD4@icloud.com> <7EAE3EDD-28E3-4585-A09A-C430DEC09916@icloud.com> <3580A52D-F771-423D-8884-A7649348E396@icloud.com> From: Mark Kirkwood Message-ID: <635fe574-b95a-dc26-24d9-6518c86f0363@catalyst.net.nz> Date: Thu, 4 Jan 2018 14:37:55 +1300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <3580A52D-F771-423D-8884-A7649348E396@icloud.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Authentication-Results: auth=pass smtp.auth=mark.kirkwood@catalyst.net.nz smtp.mailfrom=mark.kirkwood@catalyst.net.nz List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Also the Ceph version might be important (if you are running pre Jewel then there was a data corruption bug with db type workloads for 0.94.9 and earlier). regards Mark On 04/01/18 10:42, Rui DeSousa wrote: > > Interesting setup.   What is your ceph settings? Are you using caching > and is it set to write-back or write-through? > > If you’re using caching it should be using write-through with the max > dirty set to zero. > > |rbd cache max dirty| to 0 > > http://docs.ceph.com/docs/master/rbd/rbd-config-ref/ > > > >> On Jan 3, 2018, at 3:38 PM, Jorge Daniel > > wrote: >> >> We're using ceph, ext4  volumes where resides our PGDATA , it's >> mounted like this: >> /dev/rbd5 on /pg_data type ext4 >> (rw,relatime,discard,stripe=1024,data=ordered) >> >> Jorge Daniel Fernandez >> >> >> ------------------------------------------------------------------------ >> *From:*Rui DeSousa > > >> *Sent:*Wednesday, January 3, 2018 5:20 PM >> *To:*Jorge Daniel >> *Subject:*Re: pt_toast table seems to be >> I’m not a docker expert nor have I ever run Postgres in a docker >> container; but my thought is docker is not handle sync() truly to >> form — i.e. buffering for performance improvements instead.  If it >> buffers it but then crashes before the data is actual saved it will >> lead to corruption.  I’ve seen similar issues with RAID controllers >> that buffer the sync() call but eventual fail to actual save the data >> for whatever reason; buffer overrun, system crashed, etc. >> >> How is the Postgres data stored In the docker container? What file >> system is it using? Is using a docker data volume, directory mount, >> or storage plug in? >> >> Doing a quick google search it does seem that docker has it’s own >> storage model which introduces it’s own COW semantics, plugins, etc; >> although, I can’t find anything on if it guarantees sync() calls. >> >>> On Jan 3, 2018, at 2:43 PM, Jorge Daniel >> > wrote: >>> >>> Hi Rui, every time autoAnalyze ran against that table , after a long >>> time running, the OOM killer act up and killed the autovacuum , in >>> some cases the engine got in recovery and other cases it was causing >>> the crash of the whole container.  We're pretty sure that this last >>> ones were the ones that lead to this issue. >>> >>> We were able to reproduce the OOM killing and our findings lead us >>> to a strange Docker setting for the SHMMAX: >>> >>> Linux 434d18e30d83 4.10.0-42-generic #46~16.04.1-Ubuntu SMP Mon Dec >>> 4 15:57:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux >>> postgres@434d18e30d83:~$ cat /proc/sys/kernel/shmmax >>> 18446744073692774399 >>> >>> after we a fixed that   number, we were able to run the ANALYZE and >>> Vacuum to its end without any OOM killing. >>> >>> This is related to >>> https://github.com/moby/moby/issues/16315 >>> >>> I don't have now that  syslog to examine if the sync() has worked >>> properly or not. >>> >>> >>> >>> Container is reporting incorrect /proc/sys/kernel/shmmax value · >>> Issue #16315 · moby/moby >>> github.com >>> BUG REPORT INFORMATION My host is Ubuntu 15.04 (kernel >>> 3.19.0-28-generic) docker version: Client version: 1.5.0 Client API >>> version: 1.17 Go version (client): go1.3.3 Git commit (client): >>> a8a31ef OS... >>> >>> >>> >>> >>> Jorge Daniel Fernandez >>> >>> >>> ------------------------------------------------------------------------ >>> *From:*Rui DeSousa >> > >>> *Sent:*Wednesday, January 3, 2018 4:23 PM >>> *To:*Jorge Daniel >>> *Cc:*pgsql-admin@lists.postgresql.org >>> >>> *Subject:*Re: pt_toast table seems to be >>> Do you mean the Postgres instance is killed or the docker instance >>> is killed?  For OOM, what’s the memory configuration and how much >>> swap is allocated? >>> >>> I would look at your disk subsystem from the prospected of Postgres; >>> when it issues a sync() does your setup honor it?  If you docker >>> instance is crashing then it seems like sync() might not honored >>> which would lead to corruption issues you’re describing. >>> >>>> On Jan 3, 2018, at 10:25 AM, Jorge Daniel >>> > wrote: >>>> >>>> Hi guys >>>> This is my first post in the comunity so my apologies in advance >>>> about the formalities. >>>> >>>> >>>> In a production db , and after several OOM killer events on the >>>> postgres running on a docker (now fixed) we remain with a kind of >>>> corrupted pg_toast 😐: >>>> >>>> >>>> 2017-11-29 23:46:13.147 PST rhost=10.149.54.5(54750) app=PostgreSQL >>>> JDBC Driver:user=veon:db=veon:ERROR: unexpected chunk number 0 >>>> (expected 1) for toast value 17143928 in pg_toast_77809 >>>> 2017-11-29 23:46:13.147 PST rhost=10.149.54.5(54750) app=PostgreSQL >>>> JDBC Driver:user=veon:db=veon:STATEMENT: SELECT "id", >>>> "needs_pumping", "needs_lucene", "surveybatchid", "ip_address", >>>> "is_open_proxy", "is_partial", "cookies", "social_media_source", >>>> "social_media_review_id", "social_media_pull_id", >>>> "social_media_pull_id_long", "source_config_unitid", >>>> "source_config_source_id", "updated", >>>> "external_id_printable_coder", "unique_reusable_id", >>>> "invite_errmsg", "reminder_errmsg", "last_seen_pagename", >>>> "last_submitted_pagename", "has_content_fields", "logid", >>>> "alertid", "language_name", "e_status", "e_reminder_status", >>>> "e_lastupdated", "e_creationdate", "e_sampleddate", >>>> "e_responsedate", "e_invitationdate", "reminderdate", >>>> "e_delivereddate", "e_remindeddate", "e_accepteddate", >>>> "e_initialfinishdate", "e_ta_completed_date", "e_expirationdate", >>>> "e_survey_method", "e_survey_source", "e_survey_type", >>>> "parse_status", "tagging_attempts", "e_optout", >>>> "e_bounce_category", "feed_fileid", "feed_file_recordid", >>>> "startdate", "e_lastname", "e_firstname", "e_address", >>>> "e_address2", "e_city", "e_state", "e_postalcode", "e_phone", >>>> "e_email", "is_mobile", "is_mobile_first", "is_mobile_finished", >>>> "is_cookie_confirmation_needed", "exclude_from_problem_tracker", >>>> "is_invitation_error", "page_number_seen_last", >>>> "page_number_seen_highest", "pages_submitted", >>>> "pages_validation_failed", "last_submit_date", "user_agent", >>>> "jsonb_fields", "thrift", "episodeid", "e_unitid", >>>> "e_committed_survey_specid", "customer_veonid", "xmin" FROM >>>> "survey_prior" WHERE survey_veon.surveyid = ANY($1) >>>> >>>> The usual fix is : >>>> >>>> REINDEX TABLE pg_toast_77809; >>>> >>>> After this we can select * from survery_prior with no problem, and >>>> we can dump the entire table if we wish it. >>>> >>>> Then the jobs resumes and we're happy until we hit again with the >>>> same error , this occurs randomly , we suspect on the UPDATE  on >>>> certain row is creating the corruption. >>>> >>>> We can't reproduce the ERROR because we can't do a full scan of the >>>> table while the error is still alive () on-call guys applies the >>>> fix inmediatly to resume production ). >>>> >>>> So how can we discover the bad-rows and expose them, or how do we >>>> check the consistency of the pt_toast table? >>>> >>>> We need this evidence to ask for window and a complete dump/restore >>>> that will wipe out this problem. >>>> >>>> Thx in advance >>>> >>>> Jorge Daniel Fernandez >