Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hT4UJ-0003mU-L6 for pgsql-performance@arkaria.postgresql.org; Tue, 21 May 2019 13:07:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hT4UI-0003O1-4m for pgsql-performance@arkaria.postgresql.org; Tue, 21 May 2019 13:07:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hT4UH-0003No-K9 for pgsql-performance@lists.postgresql.org; Tue, 21 May 2019 13:07:25 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hT4UD-00087K-Ui for pgsql-performance@postgresql.org; Tue, 21 May 2019 13:07:23 +0000 Received: by mail-wm1-x343.google.com with SMTP id t5so2838323wmh.3 for ; Tue, 21 May 2019 06:07:21 -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:references:mime-version :content-disposition:in-reply-to:user-agent; bh=rKHEzJDYY8VNqow9LqInlP6PfYqm5xOWW3mQIEg4X5s=; b=h9WNCs43e4UwNXRkdTPk8iEl8HDYf/ZfsWdhRwVz/sRgFndvgfCGPaXjAun7w8R1/q kTWL+yvWFTpnhXdCDJPeu4+7jVRYWgby5UMXdJ2S9usGTg3sWrREUfAM8wdpWUoMksGM 3icHo1GWyhDljrVYnrnA9KelTCTzyEHDS+kzJ9muefo1Css4Kk0WZtGsVH7DIQV/u6ZB yvN3tZSIEO7cMaKD1oLEe8EvxMsmSnIByyiDKRS7THATWt415T9gR4u/MtTi2feP7wcF oKZZ/vwK/qBf9QWUQN02TIQIXEftRKJhtL9mJFjaf6iaXxnOoOsJ+qV8UEOcB5Zc4qyh uH8A== 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:references :mime-version:content-disposition:in-reply-to:user-agent; bh=rKHEzJDYY8VNqow9LqInlP6PfYqm5xOWW3mQIEg4X5s=; b=jzlYK+tw9EakBCgrL0ZmJIkqEYAm/+WKz85E5s7udZQ1J9dkwdVMhBTPoT1Ob8SC3R L9SHQVU1awL/kAZ829o6BZwIQMn43CHmfcO+nDZr7TxQyXq8W6OBz+38mDMj1sERjy+H KFPUYoxBbZ7gx34RtYp7b8IcpBs/KmYznfz5IQyb7Kpba7NsuXWWu5n9Zz2xf+y3XQ03 69pkwWK2m759b3L6ZfzmieixV0m/5THBTWCVUymB4OKTNJkLudN1jjnP5sBXV8+QG1IW X7WEdaaxBWi94RNBdprwU9sNTeh6LPRyUQdAaQ2wiTjvgR7eYN1Ir50+0o1f8Owi6rS7 okCw== X-Gm-Message-State: APjAAAVHsuL4L0nRDZ3bNEtnWKtVvt17s5KyvAW1sLt69MOyH89A5lYI 0IgPXuZDs/JdjuQuQF14yHx6mQ== X-Google-Smtp-Source: APXvYqxJ4XVyxOctwS6viNz497KwqQmWJGhRr2aLpoIyQhEqR/yEr4t2dD+Q41dg0pQ0YxtXgQbKYg== X-Received: by 2002:a05:600c:551:: with SMTP id k17mr3321037wmc.35.1558444040057; Tue, 21 May 2019 06:07:20 -0700 (PDT) Received: from localhost (static-84-42-175-93.net.upcbroadband.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id l8sm24165382wrw.56.2019.05.21.06.07.15 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 21 May 2019 06:07:16 -0700 (PDT) Date: Tue, 21 May 2019 15:07:14 +0200 From: Tomas Vondra To: Mariel Cherkassky Cc: Bimal , Greg Clough , PostgreSQL mailing lists Subject: Re: Trying to handle db corruption 9.6 Message-ID: <20190521130714.4ncqlri3o224ptpx@development> References: <1909968146.4951657.1558369245203@mail.yahoo.com> <20190520210406.5paaijqd5no6imez@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716-1444-295967-dirty List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, May 21, 2019 at 12:01:31PM +0300, Mariel Cherkassky wrote: >Tomas : > >Well, when you say it does not work, why do you think so? Does it print >some error, or what? Does it even get executed? It does not seem to be >the case, judging by the log (there's no archive_command message). > >How was the "secondary machine" created? You said you have all the WAL >since then - how do you know that? > >Well, when I start the secondary in recovery mode (the primary is down, >auto failover is disabled..) it doesnt start recovering the archive wals >from the primary. The logs of the secondary : >receiving incremental file list >rsync: link_stat "/var/lib/pgsql/archive/00000002.history" failed: No such >file or directory (2) > >sent 8 bytes received 10 bytes 36.00 bytes/sec >total size is 0 speedup is 0.00 >rsync error: some files/attrs were not transferred (see previous errors) >(code 23) at main.c(1505) [receiver=3.0.6] >sh: /var/lib/pgsql/archive/00000002.history: No such file or directory >2019-05-20 09:41:33 PDT 18558 LOG: entering standby mode >2019-05-20 09:41:33 PDT 18558 LOG: invalid primary checkpoint record >2019-05-20 09:41:33 PDT 18558 LOG: invalid secondary checkpoint link in >control file >2019-05-20 09:41:33 PDT 18558 PANIC: could not locate a valid checkpoint >record >2019-05-20 09:41:33 PDT 18555 LOG: startup process (PID 18558) was >terminated by signal 6: Aborted >2019-05-20 09:41:33 PDT 18555 LOG: aborting startup due to startup >process failure >2019-05-20 09:41:33 PDT 18555 LOG: database system is shut down >2019-05-20 09:56:12 PDT 18701 LOG: database system was shut down in >recovery at 2019-05-01 09:40:02 PDT > >As I said, the secondary was down for a month and I have all the archives >of the wals in my primary. I was hoping that the secondary will use the >restore_command to restore them : >restore_command = 'rsync -avzhe ssh postgres@X.X.X.X:/var/lib/pgsql/archive/%f >/var/lib/pgsql/archive/%f ; gunzip < /var/lib/pgsql/archive/%f > %p' > >my archive_command on the primary was : >archive_command = 'gzip < %p > /var/lib/pgsql/archive/%f' > >Am I missing something ? > First of all, the way you quote message is damn confusing - there's no clear difference between your message and the message you quote. I don't know which mail client you're using, but I suppose it can be configured to quote sensibly ... Well, clearly the standby tries to fetch WAL from archive, but the rsync command fails for some reason. You're in the position to investigate further, because you can run it manually - we can't. This has nothing to do with PostgreSQL. My guess is you don't have /var/lib/pgsql/archive on the standby, and it's confusing because archive uses the same path. >Another question, If I'll run initdb and initiate a new cluster and i'll >copy the data files of my old cluster into the new one, is there any chance >that it will work ? >I mean right now, my primary is down and cant start up because it is >missing an offset file in the pg_multixtrans/offset dir. > No, because you won't have contents of system catalogs, mapping the data files to relations (tables, indexes) and containing information about the structure (which columns / data types are in the data). The data files are pretty useless on their own. It might be possible to do some manualy recovery - say, you might create the same tables in the new schema, and then guess which data files belong to them. But there are various caveats e.g. due to dropped columns, etc. -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services