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 1nj0N7-0004od-WA for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Apr 2022 15:11:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nj0N6-0004gS-Rs for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Apr 2022 15:11:28 +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 1nj0N6-0004gI-G9 for pgsql-hackers@lists.postgresql.org; Mon, 25 Apr 2022 15:11:28 +0000 Received: from mail-vs1-xe32.google.com ([2607:f8b0:4864:20::e32]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nj0N0-0005WW-1w for pgsql-hackers@postgresql.org; Mon, 25 Apr 2022 15:11:27 +0000 Received: by mail-vs1-xe32.google.com with SMTP id d2so7658217vsd.12 for ; Mon, 25 Apr 2022 08:11:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crunchydata.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bl8+T8r338SDLfXHOMlLwS2SZermElmgQu5YBL5Wnb0=; b=I/ljc280Czg9wpR7Sn6AYBSVpJij7u4oqLbo586rdf0eMpr+gNwp3/e4V2UszXoe2I Q5oSbo2xNOXQB44dr/aPSjefSkuY+24njMPC8Dhee1ZXcaf2tretQq866ngUft8r3xmj 68f1mx+/rEiL3FhtHoaRRKLt3S6YVY96gl7T169SM8mBewSK+AXHc0je5UMzoDlG6Qs0 +Y3fQB9HhMFUGY0x4FIM9mCIJneEVwWRVqsphKGh6vueu0ZTQJ4L0Qy/bRusfpStHKdH ZOKfn9zJ0fjuQucDzEB+ngjWrxOfeqoRqC8CNYqNxSNODc0R4o+2HbjY1FBUSkd9TmHj eYLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bl8+T8r338SDLfXHOMlLwS2SZermElmgQu5YBL5Wnb0=; b=p0YlsV9Q7qRhYAZr7JlOXUWtiiOcX/xR5bVC4IPw3Zkgm7G1n4ENCnlkm8z/D9vKtX PQ2IoI2S09WHeBKUZKUgp8c5SIuaMc0HvotDQoyU3sErw+NIYrAkXJ85nAEKUuPC8Q/r mU8786VYXJz5X+vDzNnv1p8fqGi1FLEH3k9zF37O+7upngxkYC8mpvlGVbmS6uVL4PPR XVqJm1AmUWJawS6tNuN57I8jLhtZxgD30eU1r4Nic85XiNsM3As5D2l0aRRguiHslgc7 dAzoit080rfZMDfSAAlY3pX1zKcGd4ex1RlvSeYAZ2p/HMSrA9ztQPOMJhrYh8R2sSzv FDdA== X-Gm-Message-State: AOAM532IcznN4ou/litFiqxc7HvY1i7JjHQVUKDk6rLB12O/tCyDiP6p wJjDMcJ6MLHlqzWFVouj5/FCznQv1g34r9PdE7ruTQ== X-Google-Smtp-Source: ABdhPJzRXfFcijrlnK0pHi4BTfg8Wwub0cHmvc4EjFWO2Yt7lGzhZFpLBrXp0+IYKuw/1eGWLU7dDSIxYrXadmhVIYM= X-Received: by 2002:a05:6102:2747:b0:32c:cc66:4979 with SMTP id p7-20020a056102274700b0032ccc664979mr1628873vsu.60.1650899481246; Mon, 25 Apr 2022 08:11:21 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: David Christensen Date: Mon, 25 Apr 2022 10:11:10 -0500 Message-ID: Subject: Re: [PATCH] Teach pg_waldump to extract FPIs from the WAL To: Michael Paquier Cc: Matthias van de Meent , PostgreSQL-development Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Apr 25, 2022 at 1:11 AM Michael Paquier wrote: > > On Sat, Apr 23, 2022 at 01:43:36PM -0500, David Christensen wrote: > > Hi Matthias, great point. Enclosed is a revised version of the patch > > that adds the fork identifier to the end if it's a non-main fork. > > Like Alvaro, I have seen cases where this would have been really > handy. So +1 from me, as well, to have more tooling like what you are > proposing. Fine for me to use one file for each block with a name > like what you are suggesting for each one of them. > > + /* we accept an empty existing directory */ > + if (stat(config.save_fpw_path, &st) == 0 && S_ISDIR(st.st_mode)) > + { > I don't think that there is any need to rely on a new logic if there > is already some code in place able to do the same work. See > verify_dir_is_empty_or_create() in pg_basebackup.c, as one example, > that relies on pg_check_dir(). I think that you'd better rely at > least on what pgcheckdir.c offers. Yeah, though I am tending towards what another user had suggested and just accepting an existing directory rather than requiring it to be empty, so thinking I might just skip this one. (Will review the file you've pointed out to see if there is a relevant function though.) > + {"raw-fpi", required_argument, NULL, 'W'}, > I think that we'd better rename this option. "fpi", that is not used > much in the user-facing docs, is additionally not adapted when we have > an other option called -w/--fullpage. I can think of > --save-fullpage. Makes sense. > + PageSetLSN(page, record->ReadRecPtr); > + /* if checksum field is non-zero then we have checksums enabled, > + * so recalculate the checksum with new LSN (yes, this is a hack) > + */ > Yeah, that looks like a hack, but putting in place a page on a cluster > that has checksums enabled would be more annoying with > zero_damaged_pages enabled if we don't do that, so that's fine by me > as-is. Perhaps you should mention that FPWs don't have their > pd_checksum updated when written. Can make a mention; you thinking just a comment in the code is sufficient, or want there to be user-visible docs as well? > + /* we will now extract the fullpage image from the XLogRecord and save > + * it to a calculated filename */ > The format of this comment is incorrect. > > + The LSN of the record with this block, formatted > + as %08x-%08X instead of the > + conventional %X/%X due to filesystem naming > + limits > The last part of the sentence about %X/%X could just be removed. That > could be confusing, at worse. Makes sense. > + PageSetLSN(page, record->ReadRecPtr); > Why is pd_lsn set? This was to make the page as extracted equivalent to the effect of applying the WAL record block on replay (the LSN and checksum both); since recovery calls this function to mark the LSN where the page came from this is why I did this as well. (I do see perhaps a case for --raw output that doesn't munge the page whatsoever, just made comparisons easier.) > git diff --check complains a bit. Can look into this. > This stuff should include some tests. With --end, the tests can > be cheap. Yeah, makes sense, will include some in the next version. David