Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kJH3a-0001TP-By for pgsql-general@arkaria.postgresql.org; Fri, 18 Sep 2020 14:08:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kJH3Y-00089l-Bk for pgsql-general@arkaria.postgresql.org; Fri, 18 Sep 2020 14:08:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kJH3X-00089c-Iz for pgsql-general@lists.postgresql.org; Fri, 18 Sep 2020 14:08:08 +0000 Received: from resqmta-ch2-05v.sys.comcast.net ([2001:558:fe21:29:69:252:207:37]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kJH3Q-00066g-OJ for pgsql-general@postgresql.org; Fri, 18 Sep 2020 14:08:06 +0000 Received: from resomta-ch2-02v.sys.comcast.net ([69.252.207.98]) by resqmta-ch2-05v.sys.comcast.net with ESMTP id JGRxkR7B3HdxAJH3OkGiib; Fri, 18 Sep 2020 14:07:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=20190202a; t=1600438078; bh=bF6gvo2MVl9+zSuSwmU0JsP07Ffhld9M9rwKQRm5AzI=; h=Received:Received:Received:From:To:Subject:Date:Message-ID: MIME-Version:Content-Type; b=eWMeGJB+BeHnPlIAX03T6ejC/mUtZGjnLbIbGRC9ihqVZbVRmx0OMgEhBuIdbM8XD kIw5wjqkmZk4zNE11q6VEPeuLAwCUbBnbhWALcFNxQYktwczAAPGJ6P1fLAjaUtyM/ /Ay5McD1pKefrFHJQ8HXAMxSmCLr5a3QJbAN4R2wKmchBIdZK9RT7FOVVzUyxTz3kx KI8vVEGFY/l10REZHwZv82sBD9hSPBuWi6FNuUiw/9DC6uyXAXNw2eJqevUXS+/NgW c9itUF87rqX8MGlP2m2Bv/wQ9eY7hbNjVH0uyyUErwaVRYV/N+gK+6IDSXC5cAH4GR PA9xZ5LxoU2hQ== Received: from jsievers.comcast.net ([12.30.159.20]) by resomta-ch2-02v.sys.comcast.net with ESMTPA id JH39kHayB87QlJH39kUYhw; Fri, 18 Sep 2020 14:07:53 +0000 X-Xfinity-VAAS: gggruggvucftvghtrhhoucdtuddrgedujedrtdeigdejfecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucevohhmtggrshhtqdftvghsihdpqfgfvfdppffquffrtefokffrnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffufhffjgfkfgggtgfgsehtqhertddtreejnecuhfhrohhmpeflvghrrhihucfuihgvvhgvrhhsuceoghhsihgvvhgvrhhsudelsegtohhmtggrshhtrdhnvghtqeenucggtffrrghtthgvrhhnpeevhfelgfeuudevudetvefgtdekheeggfehgeetheekkefhvdegvdehueehvdekveenucfkphepuddvrdeftddrudehledrvddtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehhvghlohepjhhsihgvvhgvrhhsrdgtohhmtggrshhtrdhnvghtpdhinhgvthepuddvrdeftddrudehledrvddtpdhmrghilhhfrhhomhepghhsihgvvhgvrhhsudelsegtohhmtggrshhtrdhnvghtpdhrtghpthhtohepvhgrshhumhgusggrudehudehsehgmhgrihhlrdgtohhmpdhrtghpthhtohepmhgrghhnuhhssehhrghgrghnuggvrhdrnhgvthdprhgtphhtthhopehpghhsqhhlqdhgvghnvghrrghlsehpohhsthhgrhgvshhqlhdrohhrgh X-Xfinity-VMeta: sc=-100.00;st=legit Received: from jsievers.enova.com (localhost [127.0.0.1]) by jsievers.comcast.net (Postfix) with ESMTP id B81CC26005A; Fri, 18 Sep 2020 09:07:42 -0500 (CDT) From: Jerry Sievers To: Vasu Madhineni Cc: Magnus Hagander , pgsql-general Subject: Re: multiple tables got corrupted References: Date: Fri, 18 Sep 2020 09:07:42 -0500 In-Reply-To: (Vasu Madhineni's message of "Fri, 18 Sep 2020 16:16:30 +0800") Message-ID: <87d02jkwk1.fsf@jsievers.enova.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Vasu Madhineni writes: > Hi Magnus, > > Thanks for your update. > To identify the number of tables corrupted in the database if I run > below command, Will any impact on other tables in the production > environment.=C2=A0 > > "pg_dump -f /dev/null database" Consider using pg_dump or any other means to dump *each* table individually. pg_dump is going to abort on the first case of corruption in any table that results in a read error on full scan, thus in a scenario where multiple corrupt tables is likely, you're not going to get too far w/monolithic approach. > > Thanks in advance. > > Regards, > Vasu Madhineni > > On Fri, Sep 18, 2020 at 3:42 PM Magnus Hagander > wrote: > > That depends on what the problem is and how they fix it. Most > likely yes -- especially since if you haven't enabled data > checksums you won't *know* if things are OK or not. So I'd > definitely recommend it even if things *look* OK. >=20=20=20=20 > //Magnus >=20=20=20=20 >=20=20=20=20 > On Wed, Sep 16, 2020 at 5:06 AM Vasu Madhineni < > vasumdba1515@gmail.com> wrote: >=20=20=20=20 > I could see block read I/O errors in /var/log/syslog. if > those error fixed by OS team, will it require recovery. >=20=20=20=20=20=20=20=20 > Also can i use LIMIT and OFFSET to locate corrupted rows? >=20=20=20=20=20=20=20=20 > Thanks in advance >=20=20=20=20=20=20=20=20 > Regards, > Vasu Madhineni >=20=20=20=20=20=20=20=20 > On Wed, Sep 16, 2020, 01:58 Magnus Hagander < > magnus@hagander.net> wrote: >=20=20=20=20=20=20=20=20 > Try reading them "row by row" until it breaks. That is, > SELECT * FROM ... LIMIT 1, then LIMIT 2 etc. For more > efficiency use a binary search starting at what seems > like a reasonable place looking at the size of the table > vs the first failed block to make it faster, but the > principle is the same. Once it fails, you've found a > corrupt block... >=20=20=20=20=20=20=20=20=20=20=20=20 > //Magnus >=20=20=20=20=20=20=20=20=20=20=20=20 >=20=20=20=20=20=20=20=20=20=20=20=20 > On Tue, Sep 15, 2020 at 12:46 PM Vasu Madhineni < > vasumdba1515@gmail.com> wrote: >=20=20=20=20=20=20=20=20=20=20=20=20 > Is it possible to identify which rows are corrupted > in particular tables. >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 > On Tue, Sep 15, 2020 at 5:36 PM Magnus Hagander < > magnus@hagander.net> wrote: >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 > On Tue, Sep 15, 2020 at 11:15 AM Vasu Madhineni < > vasumdba1515@gmail.com> wrote: >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 > Hi All, >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 > In one of my postgres databases multiple > tables got corrupted and followed the below > steps but still the same error. >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 > 1.SET zero_damaged_pages =3D on > 2. VACUUM=C2=A0ANALYZE, VACUUM=C2=A0FULL > but still same error.=C2=A0 >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 > That is a very destructive first attempt. I hope > you took a full disk-level backup of the database > before you did that, as it can ruin your chances > for forensics and data recovery for other issues. >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 > moh_fa=3D# VACUUM FULL; > ERROR: =C2=A0could not read block 9350 in file > "base/1156523/1270812": Input/output error >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 > Tried to take backup of tables with pg_dump > but same error. files exist physically in > base location. >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 > How to proceed on this, no backup to restore. >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 > This is clearly some sort of disk error, and with > no backups to restore you will definitely be > losing data. >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 > I'd start by figuring out which tables have no > corruption and do work, and back those up (with > pg_dump for example) as soon as possible to a > different machine -- since it's not exactly > unlikely that further disk errors will appear. >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 > Once you've done that, identify the tables, and > then try to do partial recovery. For example, if > you look at the file 1270812, how big it is? > PostgreSQL is failing to read block 9350 which > is=C2=A076595200 bytes into the file. If this is at > the very end of the file, you can for example try > to get the data out until that point with LIMIT. > If it's in the middle of the file, it gets more > ticky, but similar approaches can be done.=C2=A0 >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 > Also, unless you are running with data checksums > enabled, I wouldn't fully trust the data in the > tables that you *can* read either. Since you > clearly have disk issues, they may have caused > corruption elsewhere as well, so whatever > verification you can do against other tables, you > should do as well. >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 > You'll of course also want to check any kernel > logs or storage system logs to see if they can > give you a hint as to what happened, but they are > unlikely to actually give you something that will > help you fix the problem. >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 > > --=20 Jerry Sievers Postgres DBA/Development Consulting e: postgres.consulting@comcast.net