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 1lKLHM-0000R0-9z for pgsql-general@arkaria.postgresql.org; Thu, 11 Mar 2021 13:23:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lKLHJ-0001C8-Ty for pgsql-general@arkaria.postgresql.org; Thu, 11 Mar 2021 13:23:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lKLHJ-0001C0-IU for pgsql-general@lists.postgresql.org; Thu, 11 Mar 2021 13:23:01 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lKLHG-0000UE-AR for pgsql-general@lists.postgresql.org; Thu, 11 Mar 2021 13:23:00 +0000 Received: by mail-ej1-x629.google.com with SMTP id r17so46141801ejy.13 for ; Thu, 11 Mar 2021 05:22:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=QN88f92bqL8KiW9S2yB2hnlHfPTK7w9d3eNMUqzAe2Y=; b=hmu5CZUK1XilHChomgFKYu86Pcn3zw7xFy/cnF1WsAx7YeUHM4itCxYORKsEkLgDjv 3XWExMy3fbNbyp5cstLWJ2+urhsSvBiqs2kggf38nyf8m6PJAeWIGf3/NJ1say0hlAMf vtjS1aolA/VII2ErqYK6ERynjKft7ww8FjS1RUDJRHR5KxyIxoLKAmbTqzL60BTsXoXi X76NroyG6q2pvq5IvSewmSehx3BLHa7juKe4Aw1ASUqejyYKm2BrPXBnTS0lRsjpWp5I qluRPwjRcrlvPjak25GjGDqCz9TGHbv7mUXwZWEMOmw/4tIzyWZniG8MgnOhWSzP64rA +Zrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=QN88f92bqL8KiW9S2yB2hnlHfPTK7w9d3eNMUqzAe2Y=; b=KI0Hp84f0BfqHSoJzBQKKeigZuQEe3ZJns/cIdDVSDhuyNZiZdg7L2JCLHR+1ua7HN WqzSN1zsJ4kvEl9/tBZ1vEu+XP+yOLKdk0GB/EzmumbnGJd5rBY5mTItp/B9lam6kiHR BA779cLIiMmvGbB0rvQF1GycpahJYhNucwTBZDcU968yeTGbJIXi52S2/RP7lbltHm91 3eru0SjHveD/VdZPtsCpwVPUxL2XF2DsBflLUyLgaWjhOi87R7SwJDP4+UdmeYVkuou3 mbgADBEQLe5uwhUZcpj1ozJhgGWaPO7rS8FTfE6Jyrp0U9i5RWhxJcD93VAKv8Zegcm1 zIQw== X-Gm-Message-State: AOAM533s1OCao1myE06VJmUO5LkoJnaTmzGWfdIpdLn/OFS2G2dQ4Nbm L5Oeyt5xunxhT5LQcJy4O7fWMw== X-Google-Smtp-Source: ABdhPJxQCnj3HUJ9DtNQxTTHgXIhIINRl33CsZSpef7eKjcIhSwKJs1XS+ZWWrMhDmTyrECh2ZWhnQ== X-Received: by 2002:a17:907:76b6:: with SMTP id jw22mr3073290ejc.11.1615468977475; Thu, 11 Mar 2021 05:22:57 -0800 (PST) Received: from localhost.localdomain (217-149-174-6.nat.highway.telekom.at. [217.149.174.6]) by smtp.gmail.com with ESMTPSA id gj13sm1312494ejb.118.2021.03.11.05.22.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Mar 2021 05:22:56 -0800 (PST) Message-ID: Subject: Re: AW: Re: PostgreSQL container crash trouble. From: Laurenz Albe To: "Zwettler Markus (OIZ)" , "pgsql-general@lists.postgresql.org" Cc: Daisuke Ikeda Date: Thu, 11 Mar 2021 14:22:55 +0100 In-Reply-To: <07b9abcdad504a179325ec6431327d8e@zuerich.ch> References: <07b9abcdad504a179325ec6431327d8e@zuerich.ch> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Markus, you should know about not top-posting on these lists. On Thu, 2021-03-11 at 10:52 +0000, Zwettler Markus (OIZ) wrote: > > On Mon, 2021-03-08 at 22:30 +0900, Daisuke Ikeda wrote: > > > I'm running PostgreSQL (enabled timescaledb extension) in the following environment. > > > And I had db pod crashed error several times irregularly. > > > > > > I want to know the cause of this fail. > > > > > > 1) PostgreSQL crash and cannot start Pod.. > > > > > > [20] LOG: invalid primary checkpoint record [20] PANIC: could not locate a valid checkpoint record > > > [1] LOG: startup process (PID 20) was terminated by signal 6: Aborted > > > [1] LOG: aborting startup due to startup process failure > > > > WAL does not contain the checkpoint from before the crash. > > > > > I thought it might be WAL trouble and tried to check with pg_controldata and pg_waldump. > > > --- > > > $ pg_controldata [...] > > > Latest checkpoint location: 15/8FB002C0 > > > Latest checkpoint's REDO location: 15/8FAF3018 > > > Latest checkpoint's REDO WAL file: 00000001000000150000008F > > > [...] > > > > > > I checked the latest checkpoint's REDO WAL file. > > > > > > But the content is all zero data. I checked this situation with "od" command. > > > > > > --- > > > $ od -N 40 -A d -v pg_wal/00000001000000150000008F > > > 0000000 000000 000000 000000 000000 000000 000000 000000 000000 > > > 0000016 000000 000000 000000 000000 000000 000000 000000 000000 > > > 0000032 000000 000000 000000 000000 > > > 0000040 > > > --- > > > > Looks like modifications to this file were lost. > > > > Somehow you lost the data for a WAL segment, and you cannot recover. > > > > Of course, if you have a backup, you know what to do. > > You said use your backup. > > Wouldn't it be enough to start instance crash recovery just before the corrupted wal in that case? > > recovery_target_lsn = <> > recovery_target_inclusive = off > > No need for a backup. Correct? No, not correct. You could perhaps locate the checkpoint before that in the WAL with "pg_waldump" and manufacture an appropriate "backup_label" to start recovery from there. But by the time you reach 00000001000000150000008F, your recovery would stop, and the database would believe it was recovered. However, there might be some data modifications in the data files from a later point in time, which amounts to data corruption. WAL is called WAL because you always have to write to WAL first, only then to the data files. You cannot have a change to the data files that is not WAL logged. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com