Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YOC7j-0007MV-SN for pgsql-general@arkaria.postgresql.org; Wed, 18 Feb 2015 21:25:36 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YOC7j-00010u-Bj for pgsql-general@arkaria.postgresql.org; Wed, 18 Feb 2015 21:25:35 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YOC7i-00010l-3P for pgsql-general@postgresql.org; Wed, 18 Feb 2015 21:25:34 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YOC7d-00027I-GH for pgsql-general@postgresql.org; Wed, 18 Feb 2015 21:25:32 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 76C61210C6 for ; Wed, 18 Feb 2015 16:25:28 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute3.internal (MEProxy); Wed, 18 Feb 2015 16:25:28 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=aklaver.com; h= x-sasl-enc:message-id:date:from:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; s=mesmtp; bh=vyx3OVRiGbPyWdF07Prwz39DmQc=; b=Iub4rktRLuNZZilRXK 4Af4/yC0yVbJokxFbmlopscgm7zMZTklYDgj3qwVn7LfZn81NiB3uukNh4A+PvIS w97iAwhfaLYKwZeHzZtrSB+M+Wtu8lIO/eVEr5BYUiGkB3sZ1mn7hKlFl3+nQ5sA v41wPnsJdTctNSxP1NRPmP28Q= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=x-sasl-enc:message-id:date:from :mime-version:to:subject:references:in-reply-to:content-type :content-transfer-encoding; s=smtpout; bh=vyx3OVRiGbPyWdF07Prwz3 9DmQc=; b=mLUsY/LBVA6KVOoMgyMRMqDT2YqlDQnq/SbzOM+SNNERPtXwH3ydfr UTXVeYhabGeBdR393Q77jPyJuUzkDwjLS5/IdoJTk4WGQ42pobD60kXC3ZG2l8uN fJ1IY48SqrMCnv/C8QPOztjooyQ0Wh2OdF+fmp08ud1hzNuTy0mVk= X-Sasl-enc: zJzR0HO2x87B9jpqH9oa8hwQkG3ukzpzwCvRQTR1+GM8 1424294728 Received: from [192.168.1.4] (unknown [174.21.191.40]) by mail.messagingengine.com (Postfix) with ESMTPA id F22B2C002A5; Wed, 18 Feb 2015 16:25:27 -0500 (EST) Message-ID: <54E50347.9020906@aklaver.com> Date: Wed, 18 Feb 2015 13:25:27 -0800 From: Adrian Klaver User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: =?UTF-8?B?Ik5vdsOhaywgUGV0ciI=?= , pgsql-general@postgresql.org Subject: Re: Fwd: Data corruption after restarting replica References: In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org On 02/16/2015 02:44 AM, Novák, Petr wrote: > Hello, > > sorry for posting to second list, but as I've received no reply > there, I'm trying my luck here. > > Thanks > Petr > > > ---------- Forwarded message ---------- > From: Novák, Petr > Date: Tue, Feb 10, 2015 at 12:49 PM > Subject: Data corruption after restarting replica > To: pgsql-bugs@postgresql.org > > > Hi all, > > we're experiencing data corruption after switching streamed replica to primary. > This is not the first time I've encountered this issue, so I'l try to > describe it in more detail. > > For this particular cluster we have 6 servers in two datacenters (3 in > each). There are two instances running on each server, each with its > own port and datadir. On the first two servers in each datacenter one > instance is primary and the other is replica for the primary from the > other server. Third server holds two offsite replicas from the other > datacenter (for DR purposes) > > Each replica was set up by taking pg_basebackup from primary > (pg_basebackup -h -p 5430 -D /data2/basebackup -P -v -U > -x -c fast). Then directories from initdb were replaced with > the ones from basebackup (only the configuration files remained) and > the replica started and was successfully connected to primary. It was > running with no problem keeping up with the primary. We were > experiencing some connection problem between the two datacenters, but > replication didn't break. > > Then we needed to take one datacenter offline due to hardware > maintenance. So I've switched the applications down, verified that no > more clients were connected to primary, then shut the primary down and > restarted replica without recovery.conf and the application were > started using the new db with no problem. Other replica even > successfully reconnected to this new primary. What other replica? > > Few hours from the switch lines appeared in the server log (which > didn't appear before), indicating a corruption: > > ERROR: index "account_username_key" contains unexpected zero page at > block 1112135 > ERROR: right sibling's left-link doesn't match: block 476354 links to > 1062443 instead of expected 250322 in index "account_pkey" > > ..and many more reporting corruption in several other indexes. What happened to the primary you shut down? > > The issue was resolved by creating new indexes and dropping the > affected ones, although there were already some duplicities in the > data, that has to be resolved, as some of the indexes were unique. > > This particular case uses Postgres 9.1.14 on both primary and replica. > But I've experienced similar behavior on 9.2.9. OS Centos 6.6 in all > cases. This may mean, that there can be something wrong with our > configuration or the replication setup steps, but I've set up another > instance using the same steps with no problem. > > Fsync related setting are at their defaults. Data directories are on > RAID10 arrays, with BBUs. Filesystem is ext4 mounted with nobarrier > option. > > Database is fairly large ~120GB with several 50mil+ tables, lots of > indexes and FK constraints. It is mostly queried, > updates/inserts/deletes are only several rows/s. > > Any help will be appreciated. > > Petr Novak > > System Engineer > Avast s.r.o. > > -- Adrian Klaver adrian.klaver@aklaver.com -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general