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 1f8PSO-0007kP-12 for pgsql-bugs@arkaria.postgresql.org; Tue, 17 Apr 2018 12:11:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f8PSM-0001cz-NP for pgsql-bugs@arkaria.postgresql.org; Tue, 17 Apr 2018 12:11:30 +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 1f8PSM-0001cp-D5 for pgsql-bugs@lists.postgresql.org; Tue, 17 Apr 2018 12:11:30 +0000 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f8PSI-0003Fv-F5 for pgsql-bugs@postgresql.org; Tue, 17 Apr 2018 12:11:29 +0000 Received: by mail-wr0-x244.google.com with SMTP id w3so18232462wrg.2 for ; Tue, 17 Apr 2018 05:11:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=kRaH9jA1IE3LARik3SdIGY23NfRb2+qxloPFV7tlxcY=; b=iCp4HA8e6cvg0u8v88WYWZ87SQvetqfsmcDIsOHRkgKH6xOsdD13DpOXswC4T5kFo3 JDvAPvFYfampiQu4n1ErMe5KJZ0ee/sydwdoszk8O4v/wapbqllMkR1U34gibAWWcmcZ pJ7BMTFOfcVin0Pe9kn3JU0g94HWfbyLFrFEKHuYZor2fLQIFZS5E5g59XgYFCIlUhuc pDQlS2nnFVWxqJ7LV0fszUeP8P7Wmf8k8tDCeCM/CbdPv+o908XEEsEacP9+yVI5yNhK jhdhFjgiw2o6ZCTm0u2ke4DeC/hA7rUgweDEZ7mh8I7eafjb8lk8E2X904h3Q0lEPrZ8 o2/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=kRaH9jA1IE3LARik3SdIGY23NfRb2+qxloPFV7tlxcY=; b=iZTJUx65iyfKZ/roKoQUCCbGE5ZEDQiWmxvYnEm5ahpKdbMWtJwiUK9nbblJt5aovA pvLT3kdllWCkNLKlR2vgrgBCz4D1F1UwVz5AWD+Ik5RlYV1mCzz8DLVPfLiuYXcTjub6 4C5vnSinkzPFJoqiXup+a71cib9DnQsKiIjBuhY0GVetnXWXRWRUug2awcA5ye4fnv+x uhh0XCP7EXRXgMHg/p+uOMw87ENQp27cbkM5rwGIB4TGCXyOP4f0GzPZl9FSg1vW42/L 1YqIVf4hcRrSSXOUwcd975biyGVsRdmJAGjLPRgoAGmxiuTpN+W9T/42Ffh94jR9Py+a ur2Q== X-Gm-Message-State: ALQs6tAtScywO3nk0vXxBpOSo4mONnu99KaRP1zeHcAoxHigXc79B67E xvEfd61lmzHmLPyDuswR1rsdnA== X-Google-Smtp-Source: AIpwx49u6aDMZh84ewKezHq3ot7PFrDgDgwTwJ13gKdIgLzL92FuZLIO0e/9WATGEa/eDLNpREMxKA== X-Received: by 10.28.217.67 with SMTP id q64mr873886wmg.12.1523967083713; Tue, 17 Apr 2018 05:11:23 -0700 (PDT) Received: from [10.137.2.21] ([212.24.157.174]) by smtp.gmail.com with ESMTPSA id c130sm12686974wmh.33.2018.04.17.05.11.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Apr 2018 05:11:22 -0700 (PDT) Subject: Re: Standby corruption after master is restarted To: emre@hasegeli.com Cc: PostgreSQL Bugs , gurkan.gur@innogames.com, david.pusch@innogames.com, patrick.schmidt@innogames.com References: <30d65a09-417a-530c-d70f-7b01ed66ebc1@2ndquadrant.com> From: Tomas Vondra Message-ID: <1da55c73-4bd1-f13e-2d4b-c4049ffd73f5@2ndquadrant.com> Date: Tue, 17 Apr 2018 14:11:21 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 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 04/17/2018 10:55 AM, Emre Hasegeli wrote: >> Can you check if the "incorrect" part of the WAL segment matches some >> previous segment? Verifying that shouldn't be very difficult (just cut a >> bunch of bytes using hexdump, compare to the incorrect data). Assuming >> you still have the WAL archive, of course. That would tell us that the >> corrupted part comes from an old recycled segment. > > I had found and saved the recycled WAL file from the archive after the > incident. Here is the hexdump of it at the same position: > > 0bddfc0 3253 4830 616f 5034 5243 4d79 664f 6164 > 0bddfd0 3967 592d 7963 7967 5541 4a59 3066 4f50 > 0bddfe0 2d55 346e 4254 3559 6a4e 726b 4e30 6f52 > 0bddff0 3876 4751 4a38 5956 5f32 7234 4b55 7045 > 0bde000 d087 0005 0005 0000 e000 66bd 1dfb 0000 > 0bde010 1931 0000 0000 0000 5a43 7746 7166 6e34 > 0bde020 304e 764e 9c32 0158 5400 e709 0900 6f66 > 0bde030 0765 7375 6111 646e 6f72 6469 370d 312e > > If you compare it with the other 2 I have posted, you would notice > that the corrupted file on standby is combination of the two. The > data on it starts with the data on the master, and continues with the > data of the recycled file. The switch is at the position 0bddff8 > which is the position printed as "Minimum recovery ending location" by > pg_controldata. > OK, this seems to confirm the theory that there's a race condition between segment recycling and replicating. It's likely limited to short period after a crash, otherwise we'd probably see many more reports. But it's still just hunch - someone needs to read through the code and check how it behaves in these situations. Not sure when I'll have time for that. >> Hmmm, I see you're using SSL. I don't think that could break affect >> anything, but maybe I should try mimicking this aspect too. > > This is the connection information. Although the master shows SSL > compression is disabled in despite of being explicitly asked for. > >> primary_conninfo = 'host=MASTER_NODE port=5432 dbname=repmgr user=repmgr connect_timeout=10 sslcompression=1' Hmmm, that seems like a separate issue. When you say 'master shows SSL compression is disabled' where do you see that? regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services