Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sCKsN-004u0t-1y for pgsql-admin@arkaria.postgresql.org; Wed, 29 May 2024 15:06:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sCKsL-00FY9c-3a for pgsql-admin@arkaria.postgresql.org; Wed, 29 May 2024 15:06:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sCKsK-00FY7H-IS for pgsql-admin@lists.postgresql.org; Wed, 29 May 2024 15:06:00 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sCKsH-001MoM-Fz for pgsql-admin@lists.postgresql.org; Wed, 29 May 2024 15:05:59 +0000 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-57883b25b50so2526649a12.2 for ; Wed, 29 May 2024 08:05:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20230601.gappssmtp.com; s=20230601; t=1716995157; x=1717599957; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:autocrypt :references:in-reply-to:date:to:from:subject:message-id:from:to:cc :subject:date:message-id:reply-to; bh=9Pbzy8s1V2C/b1yB+UYp/p4IbPxRUm049MxBW//1RFI=; b=K4klUclDWKbGdn114OG3jnIThSHypmNiWbtvqQFBa711UeNtu5TfcbCa+U7eEGT3Lv yudpB5iOGdxTz5ejAJyg/mkGnWxGAAwXMmjnUwyuOvfcq/xzU0o7xuC555czQe1ShyNS TOe3GBVd1ctrqdvFeMYqrEe96VMbSzToOOjsy6z1XgzCCWtUmD5g0mHLSeXkr6IUBgQ1 23bZRy11s2h54JUn4977dglsI/5/19kJqCf3L7cPiezxkmZKwGRroZYX+shyLuKpk1ME h8u3WcqWA7FGR11f12C1wWomt7F4dkFWG4ca3pFhUfjiBJ+c+MPFVWfRrryAqdKpPpd7 YN0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716995157; x=1717599957; h=mime-version:user-agent:content-transfer-encoding:autocrypt :references:in-reply-to:date:to:from:subject:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9Pbzy8s1V2C/b1yB+UYp/p4IbPxRUm049MxBW//1RFI=; b=SDcalChSjzNCkJCgXVRmgUIoBDKjbfKGm6rWyBjwpLwutk/ofJzaTz0IvGhC5znqyA hH8X/PRLyyQ9o68hag535G8062xqBj887SpD6JelCvgKppxdYKt8M8vtvDDFPSitVYLX H2boQIgg/hk0g3ESEQjUcOhsUmgwJZyDyUwU+SnbYwksRgzX6Xxw8ZixYrqLGOG/bsgf PaJ6KOZaWiUSYrXqwqqq2IeI00qmfFJUdBHXEsigYP6TbswidJdKsvGEvJAvv0MYaJ7F vQnQIN+xR0d0Ah23IoYVTXketuL8Y0F640uMiHPYL4w0xKrg1oMim9aA2v8sD4FiMvNZ vcqw== X-Forwarded-Encrypted: i=1; AJvYcCVYggJhaR/6NrRIIXFRx7MlSFu0WYECzMzVvW+Vzrtxaypnrb4Xny4WahSMfg1tTUBxpN16aHijLRMnmmqpvzPOLTuqNsK4tr1d4s21HUc4EQ== X-Gm-Message-State: AOJu0YzEHOvSN4MrTHbFYGhbf7Hen1FKUedCo9WGENFN7KDoDpAYuNfZ m7crA8WoNKgGmBH9+7rYBf13BEDkZvat2jSKP4uYRjuPKKJN/CcnWDIW4Z3/AWM= X-Google-Smtp-Source: AGHT+IEowmIxf2wPonhHTEj4KLPIlGCExEoEzQeRyFwpTr0ln+1sb5PkyfY7cSMkbgT+7RRUD21sUw== X-Received: by 2002:a17:907:9451:b0:a62:cf3b:77af with SMTP id a640c23a62f3a-a62cf3b798emr896718166b.52.1716995155577; Wed, 29 May 2024 08:05:55 -0700 (PDT) Received: from localhost.localdomain ([2001:871:5e:ed19:7736:9a80:1156:2d8c]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a63f9e4c430sm90646466b.156.2024.05.29.08.05.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 08:05:55 -0700 (PDT) Message-ID: Subject: Re: Questions on recovery situations (not urgent) From: Laurenz Albe To: sacrophyte@gmail.com, pgsql-admin@lists.postgresql.org Date: Wed, 29 May 2024 17:05:54 +0200 In-Reply-To: References: Autocrypt: addr=laurenz.albe@cybertec.at; prefer-encrypt=mutual; keydata=mQINBGGDwAQBEADgbWy5cKXQld3N2mF+DFyiNFbi2oBl2T+XgxpPF8wTRw2D/u4bBKXP0SYSE/lA86jIVNWWU0gf1KODIkVvgJm2w4vH2VBV1b7ddVViGl1Iu+9zaRnv9wulhnH42KefepXnoean6UT1EzLM0opF/Ik0j+40TxdRtobkBprkQUyHDXWlHc2ffPs3SipyFEP9AVLf7ejRC46CXWDnsqjOBSMEW8Z4HiK/8RrPZBsKLts8dJxKF4pygOdJb0CWk8k/X1jbcfdxo+zOLjOMvJcSJ2pFdJmQHU+JufB3rePziqQ2S9Ur6sccr9XnTC1GVBWN4Lf5VHq+vf+bFJjVwg+2hrySZnAVfcOrxoqFLErr7ug1zN2nM1kcpgA4VWn4gxlJtYNYYq+9WxX5dtvnNANlG3ZCrRKQzl8lxtzoF6Zo7LUhEqPaHDwn7Rvs+IdbOn41lF5UDTJGqmC4gS/bZydW2Fy3YWm4aSaN9fgFf8D+PVkrlKAZB7gBLz1TyHjbcRf85cYF+GKKrDld5SzMB/V60VX3oP/Eo8ikFpyWaqiz1f9X7MBot3/PjJkY+wDzp3nmb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FolyOkecwI81MCdbMfT/1TqIGTOdAj5as9fAakk0jb2pXgUYQ8X1DVTR8ahSDVEaw9VTmWiSvTxvguVJ1Mb7gG4Gmh6aviDTJhfXtH4rPUNXhDLqrTH8JkJjyKROOMakIF68Hjse5vUfUxreBEOtb5r1Coa2Fe7ncJayaSE7ryrDbFqpZ 36UMAx4ulWMyqJajLNGY0DdG8qIsR5nxRhrnK/mrCidZ8F9/D3bWAl4rjtHlsztN59 +AnW5l0HsQcY9ntFL/zEBOaonjdJf Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.4 (3.50.4-1.fc39) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 2024-05-29 at 07:27 -0500, Charles Schultz wrote: > We have been learning more about postgres recovery, and I have come acros= s a couple > questions that google has not satisfactorily answered for me. >=20 > 1. pg_waldump refuses to dump a WAL saying "fatal: WAL segment size must = be a power > of two between 1 MB and 1 GB", even though I have successfully=C2=A0us= ed the WALs for > PITR. What's the magic trick to get around this fatal error? I tried u= sing a key > unwrap function (same as in postgresql.conf) to no avail. That is unlikely, because WAL segments are always within these limits (and = have a fixed size that is a power of two. Did you compress the files? If yes, you have to uncompress them before fee= ding them to "pg_waldump". > 2. As I cannot dump the WALs, how do I determine the LSN or XID of a tran= saction in > the past? That is difficult, even with "pg_waldump". WAL does not contain SQL statem= ents. At best, you can identify which files were modified and what was done with = them, so at best you can guess that a table was dropped, because a couple of file= s get deleted. But that could also have been a VACUUM (FULL). Essentially, you have to guess a good point in time to restore to. > 3. When restoring forward, I have found=C2=A0recovery_target_time does no= t work very > well (maybe lack of granularity?), and=C2=A0recovery_target_lsn is bet= ter, but > =C2=A0pg_current_wal_lsn() only gives me the LSN before a transaction. = Is there a way > to get the XID of a specific transaction? "recovery_target_time" works just fine. The function pg_current_xact_id() gives you the current transaction ID. If you know ahead of time that you may want to restore to a certain point, you can use the function pg_create_restore_point() to define a restore poin= t to which you can restore using the parameter "recovery_target_name". > 4. How would I get the OID of a database and a table when the database=C2= =A0is down? > I wish to map the filesystem names to database objects after a crash. > Is there a tool/app that can parse pg datafiles? I have to assume that= if > there is not already one, it is not too hard to write such a tool if o= ne > has experience with PG file headers and reading the opensource=C2=A0co= de. I am not aware of such a tool, other than "postgres". You can start the server and use "oid2name". Yours, Laurenz Albe