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 1jiRzN-00055F-Fr for pgsql-general@arkaria.postgresql.org; Tue, 09 Jun 2020 00:19:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jiRzM-0000ja-Er for pgsql-general@arkaria.postgresql.org; Tue, 09 Jun 2020 00:19:36 +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 1jiRww-0003AH-TX for pgsql-general@lists.postgresql.org; Tue, 09 Jun 2020 00:17:07 +0000 Received: from uucp.dinoex.sub.de ([2001:1440:5001:1::2] helo=uucp.dinoex.org) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jiRws-0007Yd-SO for pgsql-general@lists.postgresql.org; Tue, 09 Jun 2020 00:17:05 +0000 Received: from uucp.dinoex.sub.de (uucp.dinoex.org [185.220.148.12]) by uucp.dinoex.org (8.16.0.45/8.16.0.45) with ESMTPS id 0590GdeU013770 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO) for ; Tue, 9 Jun 2020 02:16:39 +0200 (CEST) (envelope-from pmc@citylink.dinoex.sub.org) X-MDaemon-Deliver-To: X-Authentication-Warning: uucp.dinoex.sub.de: Host uucp.dinoex.org [185.220.148.12] claimed to be uucp.dinoex.sub.de Received: (from uucp@localhost) by uucp.dinoex.sub.de (8.16.0.45/8.16.0.45/Submit) with UUCP id 0590Gdrj013769 for pgsql-general@lists.postgresql.org; Tue, 9 Jun 2020 02:16:39 +0200 (CEST) (envelope-from pmc@citylink.dinoex.sub.org) Received: from gate.oper.dinoex.org (gate-e [192.168.98.2]) by citylink.dinoex.sub.de (8.15.2/8.15.2) with ESMTP id 05904twi024473 for ; Tue, 9 Jun 2020 02:04:55 +0200 (CEST) (envelope-from peter@gate.oper.dinoex.org) Received: from gate.oper.dinoex.org (gate-e [192.168.98.2]) by gate.oper.dinoex.org (8.15.2/8.15.2) with ESMTP id 05902rOF024237 for ; Tue, 9 Jun 2020 02:02:53 +0200 (CEST) (envelope-from peter@gate.oper.dinoex.org) Received: (from peter@localhost) by gate.oper.dinoex.org (8.15.2/8.15.2/Submit) id 05902r0T024236 for pgsql-general@lists.postgresql.org; Tue, 9 Jun 2020 02:02:53 +0200 (CEST) (envelope-from peter) Date: Tue, 9 Jun 2020 02:02:53 +0200 From: Peter To: pgsql-general@lists.postgresql.org Subject: 12.2: Why do my Redo Logs disappear?? Message-ID: <20200609000253.GA21670@gate.oper.dinoex.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Milter: Spamilter (Reciever: uucp.dinoex.sub.de; Sender-ip: 185.220.148.12; Sender-helo: uucp.dinoex.sub.de;) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (uucp.dinoex.org [185.220.148.12]); Tue, 09 Jun 2020 02:16:42 +0200 (CEST) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi all, this is a 12.2 Release on FreeBSD 11.3. I am doing RedoLog Archiving according to Docs Chapter 25.1. During the last week I have lost 4 distinct Redo Logs; they are not in the backup. Loosing a RedoLog is very bad, because there is no redundancy, loosing a single one of them makes the timeline disappear and it will only reappear after another Base Backup. Very very bad. So I did analyze the matter. There are three ways to restart a Berkeley machine: 1. Cowboy it (aka pull-the-plug). This makes sure that everything is certainly dead immediately, and, given all hard- and software is well designed, nothing bad should happen. 2. Shut it down. This is the official means, and it takes very long, because each and every applications are signalled and given time to bring up whatever objections they may have. In this case "pg_ctl stop" will be invoked with whatever options the sysop has configured, and postgres will copy out a full log into archive before terminating. 3. Halt/Reboot it, like this: https://www.freebsd.org/cgi/man.cgi?query=reboot&sektion=8&manpath=FreeBSD+11.3-RELEASE This is considered more safe than pull-the-plug, and still fast. Applications are killed without much waiting, but all disk buffers are flushed to permanent storage and filesystems closed. In this case, it seems, Postgres will delete the current log without archiving it. :( What precisely happens (according to the OS sources) during reboot is this: processes will be sent SIGTERM, and after some 2-10 seconds followed by SIGKILL. -------------------------------------- Lets have a closer look: We did a regular shutdown at 17:09, and then we did a reboot at 19:24. Here is the content of the staging area (where the logs are copied to and accumulated until it is worth to run a backup job): # dir arch/ total 240 drwx------ 2 postgres postgres 5 Jun 8 17:09 . drwxr-xr-x 6 postgres postgres 7 Jun 8 17:09 .. -rw------- 1 postgres postgres 16777216 Jun 8 09:38 0000000100000017000000FC.ok -rw------- 1 postgres postgres 16777216 Jun 8 10:48 0000000100000017000000FD.ok -rw------- 1 postgres postgres 16777216 Jun 8 17:09 0000000100000017000000FE.ok And here is the pg_wal directory: # dir data12/pg_wal/ total 89256 drwx------ 3 postgres postgres 10 Jun 8 19:28 . drwx------ 19 postgres postgres 23 Jun 8 19:28 .. -rw------- 1 postgres postgres 335 Jun 7 07:36 0000000100000017000000EF.00000060.backup -rw------- 1 postgres postgres 16777216 Jun 8 19:38 000000010000001800000000 -rw------- 1 postgres postgres 16777216 Jun 7 07:17 000000010000001800000001 -rw------- 1 postgres postgres 16777216 Jun 7 07:17 000000010000001800000002 -rw------- 1 postgres postgres 16777216 Jun 7 07:17 000000010000001800000003 -rw------- 1 postgres postgres 16777216 Jun 7 07:17 000000010000001800000004 -rw------- 1 postgres postgres 16777216 Jun 7 07:36 000000010000001800000005 drwx------ 2 postgres postgres 3 Jun 8 17:09 archive_status # dir data12/pg_wal/archive_status total 23 drwx------ 2 postgres postgres 3 Jun 8 17:09 . drwx------ 3 postgres postgres 10 Jun 8 19:28 .. -rw------- 1 postgres postgres 0 Jun 7 07:36 0000000100000017000000EF.00000060.backup.done Now where the hell is my "FF" log ??? Lets check syslog - this was the full shutdown at 17:09: Jun 8 17:09:38 admn pg-bck[73534]: [10-1] :[] LOG: 00000: received fast shutdown request Jun 8 17:09:38 admn pg-bck[73534]: [10-2] :[] LOCATION: pmdie, postmaster.c:2780 Jun 8 17:09:38 admn pg-bck[73534]: [11-1] :[] LOG: 00000: aborting any active transactions Jun 8 17:09:38 admn pg-bck[73534]: [11-2] :[] LOCATION: pmdie, postmaster.c:2813 Jun 8 17:09:38 admn pg-bck[73549]: [10-1] :[] DEBUG: 00000: logical replication launcher shutting down Jun 8 17:09:38 admn pg-bck[73549]: [10-2] :[] LOCATION: ProcessInterrupts, postgres.c:2981 Jun 8 17:09:38 admn pg-bck[73534]: [12-1] :[] LOG: 00000: background worker "logical replication launcher" (PID 73549) exited with exit code 1 Jun 8 17:09:38 admn pg-bck[73534]: [12-2] :[] LOCATION: LogChildExit, postmaster.c:3657 Jun 8 17:09:38 admn pg-bck[73544]: [13-1] :[] LOG: 00000: shutting down Jun 8 17:09:38 admn pg-bck[73544]: [13-2] :[] LOCATION: ShutdownXLOG, xlog.c:8321 Jun 8 17:09:45 admn pg-bck[82223]: RedoLog.bck invoked pg_wal/0000000100000017000000FE 0000000100000017000000FE Jun 8 17:09:45 admn pg-bck[82223]: RedoLog.bck pg_wal/0000000100000017000000FE 0000000100000017000000FE returns 0 Jun 8 17:09:45 admn pg-bck[73547]: [8-1] :[] DEBUG: 00000: archived write-ahead log file "0000000100000017000000FE" Jun 8 17:09:45 admn pg-bck[73547]: [8-2] :[] LOCATION: pgarch_archiveXlog, pgarch.c:675 Jun 8 17:09:55 admn pg-bck[73544]: [14-1] :[] LOG: 00000: checkpoint starting: shutdown immediate Jun 8 17:09:55 admn pg-bck[73544]: [14-2] :[] LOCATION: LogCheckpointStart, xlog.c:8362 Jun 8 17:09:55 admn pg-bck[73544]: [15-1] :[] DEBUG: 00000: performing replication slot checkpoint Jun 8 17:09:55 admn pg-bck[73544]: [15-2] :[] LOCATION: CheckPointReplicationSlots, slot.c:1078 Jun 8 17:09:55 admn pg-bck[73544]: [16-1] :[] LOG: 00000: checkpoint complete: wrote 0 buffers (0.0%); 0 WAL file(s) added, 1 removed, 0 recycled; write=0.000 s, sync=0.000 s, total=10.131 s; sync files=0, longest=0.000 s, average=0.000 s; distance=16383 kB, estimate=16383 kB Jun 8 17:09:55 admn pg-bck[73544]: [16-2] :[] LOCATION: LogCheckpointEnd, xlog.c:8435 Jun 8 17:09:55 admn pg-bck[73534]: [13-1] :[] LOG: 00000: database system is shut down Jun 8 17:09:55 admn pg-bck[73534]: [13-2] :[] LOCATION: UnlinkLockFiles, miscinit.c:859 So, "FE" was copied out okay, and we have it in the staging area. And here is the relevant stuff from the following startup - here we consequentially are within the "FF" log: Jun 8 17:15:38 admn pg-bck[6366]: [8-1] :[] LOG: 00000: database system was shut down at 2020-06-08 17:09:55 CEST Jun 8 17:15:38 admn pg-bck[6366]: [8-2] :[] LOCATION: StartupXLOG, xlog.c:6242 Jun 8 17:15:38 admn pg-bck[6366]: [9-1] :[] DEBUG: 00000: checkpoint record is at 17/FF000024 Jun 8 17:15:38 admn pg-bck[6366]: [9-2] :[] LOCATION: StartupXLOG, xlog.c:6532 Jun 8 17:15:38 admn pg-bck[6366]: [10-1] :[] DEBUG: 00000: redo record is at 17/FF000024; shutdown true ----------------------------------------