Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1erGDv-00006h-55 for pgsql-admin@arkaria.postgresql.org; Thu, 01 Mar 2018 04:53:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1erGDu-0004uU-CD for pgsql-admin@arkaria.postgresql.org; Thu, 01 Mar 2018 04:53: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_SHA384:256) (Exim 4.89) (envelope-from ) id 1erGC5-0007E1-GG for pgsql-admin@lists.postgresql.org; Thu, 01 Mar 2018 04:51:49 +0000 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1erGC1-0004Z6-Ak for pgsql-admin@lists.postgresql.org; Thu, 01 Mar 2018 04:51:48 +0000 Received: by mail-pl0-x242.google.com with SMTP id c11-v6so3005511plo.0 for ; Wed, 28 Feb 2018 20:51:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=QTZQfDpwZQfIoztVCcs/6gwOBn7/KEZECGelEJ4A8fQ=; b=gOJNmPUkZwYbsWKJU/Wf0llZeOgkGgJ+ymoubiQCo2+GLCD1WHZYiSO3SPxTMvHMTe YA7GQ+3+WUwD3L3I3gjMCpBagEtddb7R+89MTihnkkEQi7/TsPGkn2KUVJzxSe6FydIe HsH7wHwRDDvJIkj/G3M9JFpczvcJrWyE2mxGFCVW8Mlh/ZPSHRDQLZL0qhezam4Mlf35 7fCjeHcNBG4Syp8CTVOiw7jMC1secUamaxaTqN4ko446ied/cG/GCkf3ol4qvX57rqFy 4q+e39jgtq6rkSvqHAWiW0mmXDgffsp1uFtMDA6nu/9DK+lC+nMG9Uhla+si3piYD2M0 liXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=QTZQfDpwZQfIoztVCcs/6gwOBn7/KEZECGelEJ4A8fQ=; b=GMPtmgLliafl/IedD5Gp8QwrbTQ/62mBrkqjssm0PESNtVD6S/MCj45hAgZC7pAvCq H5nntd7qf2sjASWG1AEKbLLvCT3atxqRt8EWOWCSWz3uD/gPu7X5XAYTf3lsfUiMKVM4 8QrzR4Rf3OeLQQ7l8/9edVAOs09i+U4WNTHq2BCuriTwrhIJxHBqpfWx9oHdRuX/naoz c3LFoC92byy72N23dRnu63CbDrnGEklkCJbacv3Z0Ff2+trQu1U8AoNHsVZYgUjUETEl L6NXkP6oKEDmG8FUCcs4Z4PIJWlOYgfrnlIBqQBqSk8I6AmmObURtpHYM2kCauZtARbs 9y4w== X-Gm-Message-State: APf1xPB/kBrgAy2kyuxz3axgbXLy2jm5B/WxPaV7gpRAj8kqk+8OHk6v lgwIXXXbMLz5abrPRRcstMCyTurfYlZ5xaXsD8WCXHURNQfecTtwwB1rfzcZeOsuur8wsy3T004 IWY7vI32sbl0C2q0139E4G5eMWWVmbNjWFJh0SQolpKIUptSKqfdsBeVS3JsKrl+0Yci/+0QGk0 c4/qTYTblNKRM4 X-Google-Smtp-Source: AG47ELvgZxDGq2FMc472Xz7FlWuKyLIyxIXoW2W9XarkdS6gOmjWpQkfgCdgY6fBKDh/YulfZB+wPA== X-Received: by 2002:a17:902:6789:: with SMTP id g9-v6mr652672plk.167.1519879901199; Wed, 28 Feb 2018 20:51:41 -0800 (PST) Received: from osaka.octopusnet (p4600172-ipngn26001marunouchi.tokyo.ocn.ne.jp. [122.26.228.172]) by smtp.gmail.com with ESMTPSA id y14sm4900154pgs.70.2018.02.28.20.51.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Feb 2018 20:51:40 -0800 (PST) Subject: Re: WAL segment not replicated To: Ted EH , pgsql-admin@lists.postgresql.org References: From: Ian Barwick Message-ID: Date: Thu, 1 Mar 2018 13:51:28 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 03/01/2018 11:43 AM, Ted EH wrote: > I have a 2 node active/standby setup, with synchronous streaming enabled. > > WAL segments are replicated as expected on the standby. > > However, if I manually kill the postgres process with pkill on the primary Why are you using pkill (and how)? > I'm ending up with a standby WAL behind that of the primary. The primary > seems to be incrementing its WAL automatically after I restart it. > > Example: > Before killing the pg process: > Primary & standby seem to be synchronizing synchronously: > > pg_last_wal_receive_lsn > ------------------------- > 0/5E0108B0 > (1 row) > > pg_current_wal_lsn > -------------------- > 0/5E0108B0 > (1 row) > > Now I do "pkill postgres", on the primary the WAL dir has > 00000001000000000000005F as the lastest segment (file) (supposed to be 5E, but unexpectedly getting incremented) > while the standby has: > 00000001000000000000005E as its lastest segment > > The problem is if I want to restart the primary as a standby (swapping the roles), > it will complain about asking for a WAL too far in the future that is not available > on the new primary (old standby): > > could not receive data from WAL stream: ERROR: requested starting point 0/5F000000 is ahead of the WAL flush position of this server 0/5E0CBF38 > > requested starting point 0/5F000000 is ahead of the WAL flush position of this server 0/5E0D3200 > > Isn't the primary (original primary) expected to know how far is its standby? Nope. Once you promote the standby, it's an independent node; what happens on the original primary is of no consequence. If the primary was shut down cleanly *before* the standby was promoted, you should be able to reattach it as a standby. However it sounds like you've forced an unclean shutdown of your (former) primary without everything being flushed to the standby. After restarting the (former) primary it's probably gone into automatic recovery, replaying some WAL not flushed to the standby, thus creating a divergence from your standby, which can't be resolved without manual intervention. > Doing a base backup recovery is not an option for me at this point. > > This is "pg_ctl (PostgreSQL) 10.2" pg_rewind could potentially help: https://www.postgresql.org/docs/current/static/app-pgrewind.html Regards Ian Barwick -- Ian Barwick http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services