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 1nUlRa-0002Qe-Lw for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Mar 2022 08:25:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nUlQa-0004TB-Dn for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Mar 2022 08:24:12 +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 1nUlQa-0004T2-2Y for pgsql-hackers@lists.postgresql.org; Thu, 17 Mar 2022 08:24:12 +0000 Received: from mail-vk1-xa2c.google.com ([2607:f8b0:4864:20::a2c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nUlQW-0006Rg-9S for pgsql-hackers@lists.postgresql.org; Thu, 17 Mar 2022 08:24:11 +0000 Received: by mail-vk1-xa2c.google.com with SMTP id d6so2425213vkn.7 for ; Thu, 17 Mar 2022 01:24:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/pajJqU4pUaeLedw6TdhszdOzkqtqV8gRDpZJhxuTII=; b=TNMT5QVxDFkvvj3w7NtZaAwZ1hQkU0tRRAYsAk47UEOmYTfiPtZf0FZ3rG2ye+RzBh ohuvlrIcdXHjwU7eaamPVQ/AHSfupKJrAYMDr1x2DrQJ2WEMk/Vubr6KsewgOmwZK6h0 sdpdjVTfrOgAUBk6l7ppj3cZ1Y4+bpjckdkeb7d6W5AXd0Vq70mVHSwXh60OFjB095QZ kovy7UWLWFtbYvIW4m+mBYGtywgqo6/E1hBLFkoK2cZZlHRKkZYrqK1PzwQSCRbzO4cx QrGdK3JCfq1M4Q3X0lHjvCib4xcKShpIpWSQTX5qmzlDGCXNapUKQtXPkZLcRxMTuxDt 0oCQ== 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=/pajJqU4pUaeLedw6TdhszdOzkqtqV8gRDpZJhxuTII=; b=ZXkZ4scmIkHc5KFY7ZCJ0q4FdpdNjGdYBfCEJXIaAyrAlIvskMiYC1It1kNITP5IdU q7JFVx26mqtdTOfBltSEdHPe/f8FhwUKqvmcJkha+9Nk2GcpOP0Gqfa4MKIJag0C88iM tnS7eoFQYxoLfxt/bdiLm/jGSJozznYoj2n8Wy3h3dLLg5HswKJEkpB4zjY8R8rebS4I LKnZbpLi8jT7TjF6M16ffBNK/f3uo33bqQmxpMj2GzRQbBV/8oVHC2f3R9YYdIjQGWxJ z27T7SCm4d1DCjI0E0TzqALzl1/oYKarlIfAHlnbWULOjcyIvujG323MRpYIVY+ZkYa6 rPPw== X-Gm-Message-State: AOAM531YVgsIIK9fTJVQUfpQcJhDH48dRNMwVJYixceMT6wXkCWC1/8S FlpnCqyxUkEeEW5u71Ea1suBPpHE+e531vM86KU= X-Google-Smtp-Source: ABdhPJyMtYILz/0myQdcUtzJPIkuRmZZSd+cMUUYoObYr0iEK2yG67VXRv+9Zs+WmMgLduH7cgCqveRKVrQm//jaY3Q= X-Received: by 2002:a05:6122:20a9:b0:33e:27bc:edef with SMTP id i41-20020a05612220a900b0033e27bcedefmr1211294vkd.13.1647505447209; Thu, 17 Mar 2022 01:24:07 -0700 (PDT) MIME-Version: 1.0 References: <20220316142658.GS10577@tamriel.snowman.net> <20220317.141838.2298774060802316987.horikyota.ntt@gmail.com> In-Reply-To: <20220317.141838.2298774060802316987.horikyota.ntt@gmail.com> From: Bharath Rupireddy Date: Thu, 17 Mar 2022 13:53:55 +0530 Message-ID: Subject: Re: pg_walinspect - a new extension to get raw WAL data and WAL stats To: Kyotaro Horiguchi Cc: Ashutosh Sharma , Stephen Frost , Jeff Davis , Robert Haas , Andrew Dunstan , Greg Stark , Jeremy Schneider , Bruce Momjian , PostgreSQL Hackers , SATYANARAYANA NARLAPURAM , marvin_liang@qq.com, actyzhang@outlook.com Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Mar 17, 2022 at 10:48 AM Kyotaro Horiguchi wrote: > > It still suggests unspecifiable end-LSN.. > > > select * from pg_get_wal_records_info('4/4B28EB68', '4/4C000060'); > > ERROR: cannot accept future end LSN > > DETAIL: Last known WAL LSN on the database system is 4/4C000060. Thanks Kyotaro-san. We can change the detail message to show (current flush lsn/last replayed lsn - 1), that's what I've done in v11 posted upthread at [1]. The problem is that all the pg_walinspect functions would wait for the first valid record in read_local_xlog_page() via InitXLogReaderState()->XLogFindNextRecord(), see[2]. We have two things to do: 1) Just document the behaviour "pg_walinspect functions will wait for the first valid WAL record if there is none found after the specified input LSN/start LSN.". This seems easier but some may see it as a problem. 2) Have read_local_xlog_page_2 which doesn't wait for future WAL LSN unlike read_local_xlog_page and like pg_waldump's WALDumpReadPage. It requires a new function read_local_xlog_page_2 that almost looks like read_local_xlog_page except wait (pg_usleep) loop, we can avoid code duplication by moving the read_local_xlog_page code to a static function read_local_xlog_page_guts(existing params, bool wait): read_local_xlog_page(params) read_local_xlog_page_guts(existing params, false); read_local_xlog_page_2(params) read_local_xlog_page_guts(existing params, true); read_local_xlog_page_guts: if (wait) wait for future wal; ---> existing pg_usleep code in read_local_xlog_page. else return; I'm fine either way, please let me know your thoughts on this? [1] https://www.postgresql.org/message-id/CALj2ACU8XjbYbMwh5x6hEUJdpRoG9%3DPO52_tuOSf1%3DMO7WtsmQ%40mail.gmail.com [2] postgres=# select pg_current_wal_flush_lsn(); pg_current_wal_flush_lsn -------------------------- 0/1624430 (1 row) postgres=# select * from pg_get_wal_record_info('0/1624430'); ERROR: cannot accept future input LSN DETAIL: Last known WAL LSN on the database system is 0/162442F. postgres=# select * from pg_get_wal_record_info('0/162442f'); ---> waits for the first valid record in read_local_xlog_page. Regards, Bharath Rupireddy.