Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iF8kM-0003Uc-Bl for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Oct 2019 03:22:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iF8kL-0000x5-4P for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Oct 2019 03:22:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iF8kK-0000ww-OJ for pgsql-hackers@lists.postgresql.org; Tue, 01 Oct 2019 03:22:40 +0000 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iF8kE-0001CT-5M for pgsql-hackers@postgresql.org; Tue, 01 Oct 2019 03:22:40 +0000 Received: by mail-pg1-x542.google.com with SMTP id a3so8593895pgm.13 for ; Mon, 30 Sep 2019 20:22:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:to:cc:subject:from:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=NHsBRJQ/22MoF32krK09n5O3Iynq8eYoTp2jjUQPNI8=; b=PALUfWCQBs8wQX9mmeDN+6+s+rEHiwmtAhNGraAG3SKZMer3iYLe0OV4ureYnc+8SO fwx7t5bw5cpptIl8fTB2z5U8CkKkjNWA+UehSPYqr/VPY5qMAJS0KtfTe0nJuen6cz28 WipBLaRnasnlsfY6OQ7EDon94iHRAhAieg2lRgA1SR6MC6O55q4go/btmZhpHkg/hO/o C5xJbPhNZp2GzG5hMyoDBD0gtpG9iGGUYyN9J6buanjZsjnSKXeTZ4t864prn4zIcGu+ r5pOHzlHkT/xFgpLefn7ja3LSXmBL81tQgsQXI0Ry/YgZ3/3T5XMgJxG50pmCi32TInh dTrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:to:cc:subject:from:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=NHsBRJQ/22MoF32krK09n5O3Iynq8eYoTp2jjUQPNI8=; b=J4/lZwtXTQ/EVm+v3d2n0KkuW9u+MMOeS6MUTsKyPJFhmP1ZNuJ5Ff7CgfrRyLbf9z 8HVAgrrV1b/ISkkJNX1c5yN1DZQgJJ1CPzfExTFbzFTIZMMEUMg1/6birDhMneUiTQlZ i/lVnSJOrNrJ8vCqm+VOYYYunt0xBTvtWEEab0yOqRV7KHZ79lAD+Mvf5U+4Ry/6k8r/ 8PU+4DbAHiSIlVjAg2ux8w25p1+PYIQKv2OLWfNIcSRti7ZrEvlL7HUQ4APG2MwAOV2O Ig3OGazU8EmtBWz521CxLlZ6rfg7crfdg+xZ0Ro3mOvoSrRcGlGqXWJYpe9EWtSXFCvu VXpQ== X-Gm-Message-State: APjAAAVsuMoQDwz125VumL903N4Z+BLZ1JEMi/oiZWf26AUlQIUUJD8O 43CFCftmc9IFr6IBDKcwBfI= X-Google-Smtp-Source: APXvYqyVhoRgyGK0ScAk6KqHQQuTfUAJVCG7aAQQwCgFuc0gnT1lLtM4tID1Jduj07HKAZsWSp2W+A== X-Received: by 2002:a17:90a:2766:: with SMTP id o93mr2898219pje.40.1569900151657; Mon, 30 Sep 2019 20:22:31 -0700 (PDT) Received: from localhost (w204177.dynamic.ppp.asahi-net.or.jp. [121.1.204.177]) by smtp.gmail.com with ESMTPSA id k5sm19377459pfp.109.2019.09.30.20.22.28 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 30 Sep 2019 20:22:31 -0700 (PDT) Date: Tue, 01 Oct 2019 12:22:27 +0900 (Tokyo Standard Time) Message-Id: <20191001.122227.209046280.horikyota.ntt@gmail.com> To: ah@cybertec.at Cc: alvherre@2ndquadrant.com, thomas.munro@gmail.com, robertmhaas@gmail.com, pgsql-hackers@postgresql.org Subject: Re: Attempt to consolidate reading of XLOG page From: Kyotaro Horiguchi In-Reply-To: <9236.1569675635@antos> References: <20190927191736.GA13447@alvherre.pgsql> <7753.1569658465@antos> <9236.1569675635@antos> User-Agent: Mew version 6.5 on Emacs 22.2 / Mule 5.0 =?iso-2022-jp?B?KBskQjpnGyhCKQ==?= / Meadow-3.01-dev (TSUBO-SUMIRE) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello, At Sat, 28 Sep 2019 15:00:35 +0200, Antonin Houska wrote in <9236.1569675635@antos> > Antonin Houska wrote: > > > Alvaro Herrera wrote: > > > > > BTW that tli_p business to the openSegment callback is horribly > > > inconsistent. Some callers accept a NULL tli_p, others will outright > > > crash, even though the API docs say that the callback must determine the > > > timeline. This is made more complicated by us having the TLI in "seg" > > > also. Unless I misread, the problem is again that the walsender code is > > > doing nasty stuff with globals (endSegNo). As a very minor stylistic > > > point, we prefer to have out params at the end of the signature. > > > > XLogRead() tests for NULL so it should not crash but I don't insist on doing > > it this way. XLogRead() actually does not have to care whether the "open > > segment callback" determines the TLI or not, so it (XLogRead) can always > > receive a valid pointer to seg.ws_tli. > > This is actually wrong - seg.ws_tli is not always the correct value to > pass. If seg.ws_tli refers to the segment from which data was read last time, > then XLogRead() still needs a separate argument to specify from which TLI the > current call should read. If these two differ, new file needs to be opened. openSegment represents the file *currently* opened. XLogRead needs the TLI *to be* opened. If they are different, as far as wal logical wal sender and pg_waldump is concerned, XLogRead switches to the new TLI and the new TLI is set to openSegment.ws_tli. So, it seems to me that the parameter doesn't need to be inout? It is enough that it is an "in" parameter. > The problem of walsender.c is that its implementation of XLogRead() does not > care about the TLI of the previous read. If the behavior of the new, generic > implementation should be exactly the same, we need to tell XLogRead() that in > some cases it also should not compare the current TLI to the previous > one. That's why I tried to use the NULL pointer, or the InvalidTimeLineID > earlier. Physical wal sender doesn't switch TLI. So I don't think the behavior doesn't harm (or doesn't fire). openSegment holds the TLI set at the first call. (Even if future wal sender switches TLI, the behavior should be needed.) > Another approach is to add a boolean argument "check_tli", but that still > forces caller to pass some (random) value of the tli. The concept of > InvalidTimeLineID seems to me less disturbing than this. So I think InvalidTimeLineID is not needed. regards. -- Kyotaro Horiguchi NTT Open Source Software Center