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 1v3GZU-00Dhpt-VH for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Sep 2025 16:17:52 +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 1v3GZS-002X92-4F for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Sep 2025 16:17:50 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v3GZR-002X8t-P8 for pgsql-hackers@lists.postgresql.org; Mon, 29 Sep 2025 16:17:50 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v3GZQ-000XTB-01 for pgsql-hackers@lists.postgresql.org; Mon, 29 Sep 2025 16:17:49 +0000 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-336b9473529so1802872a91.1 for ; Mon, 29 Sep 2025 09:17:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1759162668; x=1759767468; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=mhDzVvSS6zfquhuIJb4SGnC4a8C6SVYypB8WjIff8xo=; b=ZLwoH3p/6v8iHF2bAgUz7yFgD4DFEjZsxyhgue/EayNC8Xdyb7jhjRd2nkKCRUNuSi +wqJZeDQLg4yq5qEQ7PDOWy6mEujHZvIazaYOoDVQfSEFTqoiaqaPTGFLq+rA02FkUqM cbEZ8WI8VACpW+k5+eP5zUmdwdcCWOvLR//f0fWj6AGBluNe1W6mNHWgaLG1+mwQ5nw9 iM+jmEmSWbJUDIDphANUvRye5bPoEiGV0DA07ZjLPhTskVb9cCgltDExTH3bKLarM/fD uocZ8xsmlKz25L22ZadNZwLs0uRL4C0b6uwsoj9RENBnw6SOoz7MobzON9qOPUXPi39h Gkpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759162668; x=1759767468; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mhDzVvSS6zfquhuIJb4SGnC4a8C6SVYypB8WjIff8xo=; b=CLiaknAoxa7xzU2JPOT2OaHn87i4WJN+TyyEoWu6GQMY1ZUdmNDmVdo83yrFpK3y+7 3d1d+a/G8HVzxOitDR8EGBdcGWgf16O9U14pPTmvKrqFudS+9YQ/vvsOR7FvJCj/FzjX IkWRlsVuAuPRSOqDGJsHYwXJXaAy5ItBO94+OGAQAxsY9Api6c7/QaWGGNWEzqTnP8Ie /JXuapKQI+0eDySA1XdHsIYqiGZnxPv6dV9nCkpbtx2o+F+qZOu9D1pMx0lT9sWHcCbl 4vdiDkDdR/kKQ7ifQA21POz56/xMVLdKV8yz0Qe+MaLMR69RNyWBNeBxBLFOmrBpDilQ zW0Q== X-Gm-Message-State: AOJu0YxkPnkaW/lzlealCvc0ii43Ak445ixOFtSmrAR9joZ7P8RBF7/Q Bmc4ZhzA2w9iqVPVMthHaNaxPmEkOvkuhQwSAJTR6ebMHBxYsGoCN15YNHkUha+f0V4rZo+NryD J4W97TFPLFEDkr2BkX7RKczl2er3UFQ7Njg== X-Gm-Gg: ASbGncu0vT7C6aDzUeRidiFq+GAXTFR09BQgAlnIYNSEXrDmPe3JhXGzxbWihCrrJjS yomjHe5KSap62XYSjQySZfzN4xADWvTsCd3VSdd2nJnZzKnut9n38zQLewfrnu/n9dgx4IGW80L E7U78dRPbGEg7+zFyYb91kD9Fj4YqmNjXLI5NyiMoRd5msQKLyTl+DgrbCvS/HX0sUAKVAtMCwX +3uTndX3oi7IoXjdKLELWIBJY7Tag== X-Google-Smtp-Source: AGHT+IE6PeoOAgi/UJFzVTDIVxw3pE6OFsc4O94YQb48pWKjWYhca26JmppzFdeZWcm3QuZactcsAV5/7RvlZ+Tqix8= X-Received: by 2002:a17:90b:4b0b:b0:32e:dcc6:cd33 with SMTP id 98e67ed59e1d1-3383ac093f8mr1299679a91.11.1759162667578; Mon, 29 Sep 2025 09:17:47 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Amul Sul Date: Mon, 29 Sep 2025 21:47:10 +0530 X-Gm-Features: AS18NWCLkwMebtaMnmhw-L8kJVUSbCe3955FGJSGpnkkv6BgxnCdHvIcjjV0a-U Message-ID: Subject: Re: pg_waldump: support decoding of WAL inside tarfile To: Robert Haas Cc: PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Sep 29, 2025 at 8:45=E2=80=AFPM Robert Haas = wrote: > > On Thu, Sep 25, 2025 at 4:25=E2=80=AFAM Amul Sul wrot= e: > > > Another thing that isn't so nice right now is that > > > verify_tar_archive() has to open and close the archive only for > > > init_tar_archive_reader() to be called to reopen it again just moment= s > > > later. It would be nicer to open the file just once and then keep it > > > open. Here again, I wonder if the separation of duties could be a bit > > > cleaner. > > > > Prefer to keep those separate, assuming that reopening the file won't > > cause any significant harm. Let me know if you think otherwise. > > Well, I guess I'd like to know why we can't do better. I'm not really > worried about performance, but reopening the file means that you can > never make it work with reading from a pipe. I have some skepticism regarding the extra coding that might be introduced, as performance is not my primary concern here. If we aim to keep the file open only once, that logic should be implemented before calling verify_tar_archive(), not inside it. Implementing the open and close logic within verify_tar_archive() and free_tar_archive_reader() would create a confusing and scattered pattern, especially since these separate operations require only two lines of code each (open and close if it's a tar file). My second, concern is that after verify_tar_archive(), we might need to reset the file reader offset to the beginning. While reusing the buffered data from the first iteration is technically possible, that only works if the desired start LSN is at the absolute beginning of the archive, or later in the sequence, which cannot be reliably guaranteed. Therefore, for simplicity and avoid the complexity of managing that offset reset code, I am thinking of a simpler approach. Regards, Amul