Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ffsbF-00069r-Mn for pgsql-admin@arkaria.postgresql.org; Wed, 18 Jul 2018 19:59:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ffsbD-0004bc-Uo for pgsql-admin@arkaria.postgresql.org; Wed, 18 Jul 2018 19:58:59 +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.89) (envelope-from ) id 1ffsbD-0004bV-JP for pgsql-admin@lists.postgresql.org; Wed, 18 Jul 2018 19:58:59 +0000 Received: from mail-qk0-x244.google.com ([2607:f8b0:400d:c09::244]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ffsb9-0008FE-VJ for pgsql-admin@lists.postgresql.org; Wed, 18 Jul 2018 19:58:59 +0000 Received: by mail-qk0-x244.google.com with SMTP id v17-v6so3053427qkb.11 for ; Wed, 18 Jul 2018 12:58:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=jvu1yhHVOzxgMSMn7TRHEkH9N93mYFmfz87nBLfPVZU=; b=oGq9BrRosJ9ctLeFVTeyd63aFsz9w7L4zSbbWb+vwJZ2oe7DfcWq1fKwtP32Xo4+Px FKctIkwhQQV4YeEOwZDHWbmOCjI4j0R/yQirB93L6fcfjYP+vp/spDcjp62jRAB18n38 PcKmeIFDBwedceq0vJHBWVP1thz8mmR6j6rtmdjwDRxFQOtH+CNjKAWVmzGNkDXJEOhB WiyJMuBOtBB9zPmBbgiWAoaBNviqgDcLdKLilgOy+1rAjEplm1V7L1a5ir/qtRSHB3R/ Kxykn9bCGPnUK9D7ecaRUIi9z+xfiPqn15f6jkeGmDcfHYBreQ8v58+9V+Nmb2bCJ9cY 6wrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=jvu1yhHVOzxgMSMn7TRHEkH9N93mYFmfz87nBLfPVZU=; b=aVMtm8YOlRwhP6Gy6+7VbYmG32s6Hx6SkeH08KhmT8TBRvgnMTNfgBRVMd3X80q4eq yBpvJD3eaD0YLA8APM0O4ABpZatrSvhmc/CCdv5fkUXEkX9ZWYdCvpfpWuCuVLs0m47T 0P7aOtsXk6SeL6XwaY3P8lp8OI55vxV5h5siwIEXxPdd6QK/pnsQqIftHjExS6Dmo79H 5ocjfZZr7QETQ6GtEzv4cQE9NadSyECa9hB1KugjCGS12SWDs3n2PQT893oLhK9LYqYE I7Q4c6N6AzdHmwz+q1ex/MI+5HVtghC+47AdTkCX1gE8JNdcJ4+9xFpajl4pdBZ3XiNu VC1g== X-Gm-Message-State: AOUpUlExVssOKyfJHypRo78O26tzwC7LqFW4ivZiZEOU8SNPaF/udFdM z1zrSxtgA+s9mE7W3v9lOsoxUA== X-Google-Smtp-Source: AAOMgpfolbDtY2icUMgxA0v+jfDFU30vgFHLnXjDJn6vHYPuSb8yloHCa9eJaw2cZwzV0KnbzzRwPw== X-Received: by 2002:a37:7946:: with SMTP id u67-v6mr6404726qkc.283.1531943933919; Wed, 18 Jul 2018 12:58:53 -0700 (PDT) Received: from alvin.alvh.no-ip.org ([179.56.48.71]) by smtp.gmail.com with ESMTPSA id k3-v6sm3961061qta.37.2018.07.18.12.58.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 18 Jul 2018 12:58:53 -0700 (PDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 01A24CCB; Wed, 18 Jul 2018 15:58:50 -0400 (-04) Date: Wed, 18 Jul 2018 15:58:50 -0400 From: Alvaro Herrera To: Naveen Kumar Cc: pgsql-admin@lists.postgresql.org Subject: Re: ERROR: unexpected chunk number 452 (expected 0) for toast value 94674063 in pg_toast_56980977 Message-ID: <20180718195850.axhzokgbggoxpcmr@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170306-137-4415bd-dirty (1.8.0) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2018-Jul-18, Naveen Kumar wrote: > Hello Experts, > > What could be the reason for bellow errors. Can one help me to fix this? > > PostgreSQL Database: [~rptdb~] Data Backup Failed with PostgreSQL Error: > [~pg_dump: Dumping the contents of table "document" failed: PQgetResult() > failed.pg_dump: Error message from server: ERROR: unexpected chunk number > 452 (expected 0) for toast value 94674063 in pg_toast_56980977pg_dump: The > command was: COPY reports_extended.document (document_id, access_key, > created_date, document_name, document_size, document_status, document_type, > encryption_type, external_system_storage_id, external_system_storage_url, > last_updated_date, md5_hash, source_system_name, storage_type, created_by, > customer_org_id, content_type, tags, file, ownedby) TO stdout;~]. There are two related bugfixes in 9.6.9 (and all other versions released with it). Maybe you'd do well to upgrade to the latest minor of whatever supported branch you're using, and then let's discuss more. If you were victim to this bug I'm not sure there's direct mitigation, or you'll need to UPDATE the offending rows to set the columns to null (or some other value). Eight years ago (!) I wrote a function to scan for those, quoted in this blog post (sorry about my Spanish): https://alvherre.livejournal.com/4404.html May be helpful. (I think it needs a minor fix to run in current releases.) Author: Tom Lane Branch: master Release: REL_11_BR [d1e907929] 2018-04-11 18:11:29 -0400 Branch: REL_10_STABLE Release: REL_10_4 [08e6cda1c] 2018-04-11 18:11:29 -0400 Branch: REL9_6_STABLE Release: REL9_6_9 [060bb38d0] 2018-04-11 18:11:30 -0400 Branch: REL9_5_STABLE Release: REL9_5_13 [efbe36a2c] 2018-04-11 18:11:30 -0400 Branch: REL9_4_STABLE Release: REL9_4_18 [6943fb927] 2018-04-11 18:11:30 -0400 Branch: REL9_3_STABLE Release: REL9_3_23 [66d4b6bb8] 2018-04-11 18:11:30 -0400 Ignore nextOid when replaying an ONLINE checkpoint. The nextOid value is from the start of the checkpoint and may well be stale compared to values from more recent XLOG_NEXTOID records. Previously, we adopted it anyway, allowing the OID counter to go backwards during a crash. While this should be harmless, it contributed to the severity of the bug fixed in commit 0408e1ed5, by allowing duplicate TOAST OIDs to be assigned immediately following a crash. Without this error, that issue would only have arisen when TOAST objects just younger than a multiple of 2^32 OIDs were deleted and then not vacuumed in time to avoid a conflict. Pavan Deolasee Discussion: https://postgr.es/m/CABOikdOgWT2hHkYG3Wwo2cyZJq2zfs1FH0FgX-=h4OLosXHf9w@mail.gmail.com Author: Tom Lane Branch: master Release: REL_11_BR [0408e1ed5] 2018-04-11 17:41:22 -0400 Branch: REL_10_STABLE Release: REL_10_4 [5a11bf970] 2018-04-11 17:41:23 -0400 Branch: REL9_6_STABLE Release: REL9_6_9 [8bba10f7e] 2018-04-11 17:41:25 -0400 Branch: REL9_5_STABLE Release: REL9_5_13 [3767216fb] 2018-04-11 17:41:26 -0400 Branch: REL9_4_STABLE Release: REL9_4_18 [5b3ed6b78] 2018-04-11 17:41:27 -0400 Branch: REL9_3_STABLE Release: REL9_3_23 [7448e7e23] 2018-04-11 17:41:28 -0400 Do not select new object OIDs that match recently-dead entries. When selecting a new OID, we take care to avoid picking one that's already in use in the target table, so as not to create duplicates after the OID counter has wrapped around. However, up to now we used SnapshotDirty when scanning for pre-existing entries. That ignores committed-dead rows, so that we could select an OID matching a deleted-but-not-yet-vacuumed row. While that mostly worked, it has two problems: * If recently deleted, the dead row might still be visible to MVCC snapshots, creating a risk for duplicate OIDs when examining the catalogs within our own transaction. Such duplication couldn't be visible outside the object-creating transaction, though, and we've heard few if any field reports corresponding to such a symptom. * When selecting a TOAST OID, deleted toast rows definitely *are* visible to SnapshotToast, and will remain so until vacuumed away. This leads to a conflict that will manifest in errors like "unexpected chunk number 0 (expected 1) for toast value nnnnn". We've been seeing reports of such errors from the field for years, but the cause was unclear before. The fix is simple: just use SnapshotAny to search for conflicting rows. This results in a slightly longer window before object OIDs can be recycled, but that seems unlikely to create any large problems. Pavan Deolasee Discussion: https://postgr.es/m/CABOikdOgWT2hHkYG3Wwo2cyZJq2zfs1FH0FgX-=h4OLosXHf9w@mail.gmail.com -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services