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 1kr60a-0000j5-Q4 for pgsql-general@arkaria.postgresql.org; Sun, 20 Dec 2020 21:12:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kr60Y-0003cV-G6 for pgsql-general@arkaria.postgresql.org; Sun, 20 Dec 2020 21:12:50 +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 1kr487-0004xK-EF for pgsql-general@lists.postgresql.org; Sun, 20 Dec 2020 19:12:32 +0000 Received: from ip27.imatronix.com ([200.63.97.108]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kr482-0007pL-Vt for pgsql-general@postgresql.org; Sun, 20 Dec 2020 19:12:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=superfactura.cl; s=default; h=Content-Type:MIME-Version:Date:Message-ID: Subject:From:To:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=42RpYOWECZqx9ayte9lbkvcaW76QqDw3VU8jmFdmtTg=; b=l3UeUQ+bleYlhyPxVU/24XnCtw lpEoh3O2huNAWJC1kfNAY6m4GHtqVAtg5umcAWxzSlj6vCVdRTt5l/qVH61y2VUPyg17ThEBMtLZI 944YnUbPMHgbn2qYca5nXNxW6lqmqew8YwRAesam+wmOq+KyMSHzdGOrz6wmnJkoHmKROalvbiL6I K26DKpUdI3mI+8ZF2T2sB89HA4x9EMMpBVOZnzbOVPs8Lx7dbO8k6U1UGWhxsQ5vhucO4lFxq+OI9 olGSav7lM/BI/22GDjjEPC3fFwc4is1dqg60XPpfEuquLvE6yLF5k3d9pSWAlsjaCuNPvgWKTNjf2 iw4ULVPQ==; Received: from [200.73.112.45] by cpanel.imatronix.com with esmtpsa (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.93) (envelope-from ) id 1kr47x-0007Ee-Cw for pgsql-general@postgresql.org; Sun, 20 Dec 2020 16:12:21 -0300 To: pgsql-general@postgresql.org From: Christopher Pereira Subject: Prevent pg_rewind destroying the data Organization: IMATRONIX S.A. Message-ID: Date: Sun, 20 Dec 2020 16:11:25 -0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------60CB9C384F49CBA3587E04F1" Content-Language: en-US X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cpanel.imatronix.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - imatronix.cl X-Get-Message-Sender-Via: cpanel.imatronix.com: authenticated_id: soporte@superfactura.cl X-Authenticated-Sender: cpanel.imatronix.com: soporte@superfactura.cl X-Source: X-Source-Args: X-Source-Dir: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------60CB9C384F49CBA3587E04F1 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Hi, When pg_rewind is interrupted due to network errors, the cluster gets corrupted: Running pg_rewind for a second time returns "pg_rewind: fatal: target server must be shut down cleanly". Trying to fix the cluster with "/usr/pgsql-12/bin/postmaster' --single -F -D '/var/lib/pgsql/12/mydb' -c archive_mode=on -c archive_command=false" throws: LOG:  could not read from log segment 0000003B000000000000003E, offset 0: read 0 of 8192 LOG:  invalid primary checkpoint record PANIC:  could not locate a valid checkpoint record When a cluster failsover because of a network problem, chances are high that another network problem may occur while we run pg_rewind. It would be nice if pg_rewind wouldn't destroy the data and leave the cluster in a state where retrying pg_rewind can succeed. As a workaround we are thinking in taking a LVM snapshot or do a "cp --reflink" before running pg_rewind and restore if there is a failure, but it would be nice if pg_rewind were "non destructive". Is this possible? Am I missing something? We are using PG 12. --------------60CB9C384F49CBA3587E04F1 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

Hi,

When pg_rewind is interrupted due to network errors, the cluster gets corrupted:

Running pg_rewind for a second time returns "pg_rewind: fatal: target server must be shut down cleanly".

Trying to fix the cluster with "/usr/pgsql-12/bin/postmaster' --single -F -D '/var/lib/pgsql/12/mydb' -c archive_mode=on -c archive_command=false" throws:

LOG:  could not read from log segment 0000003B000000000000003E, offset 0: read 0 of 8192
LOG:  invalid primary checkpoint record
PANIC:  could not locate a valid checkpoint record

When a cluster failsover because of a network problem, chances are high that another network problem may occur while we run pg_rewind.
It would be nice if pg_rewind wouldn't destroy the data and leave the cluster in a state where retrying pg_rewind can succeed.

As a workaround we are thinking in taking a LVM snapshot or do a "cp --reflink" before running pg_rewind and restore if there is a failure, but it would be nice if pg_rewind were "non destructive".

Is this possible?
Am I missing something?

We are using PG 12.

--------------60CB9C384F49CBA3587E04F1--