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 1mWI39-0008QN-0e for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Oct 2021 12:54:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mWI37-0000Gk-Uz for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Oct 2021 12:54:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mWI37-0000Gc-3t for pgsql-hackers@lists.postgresql.org; Fri, 01 Oct 2021 12:54:01 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mWI32-0008Bm-J9 for pgsql-hackers@lists.postgresql.org; Fri, 01 Oct 2021 12:54:00 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 174EB3201D4C; Fri, 1 Oct 2021 08:53:52 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 01 Oct 2021 08:53:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=RqoNxeLhxTEt5ub8C3tbQ+z5IDHhnZP3NqaxeMG6Cgg=; b=MAZ03i2s +rl5NeOAhnr9MtMVQzIqqo4SKVoLD4lChh6CUpGU6mUVLfIXgljE8SttP1E0wWQV FNkH3woMlx6ijV5c+Niu7kEr6X2CZXKjbhOthKIXjNu3anv6pOqeRAj5SE1pEEHl 67HR31VPJYZHfPg1nchTqHXEnw+27UMgqjaMedpwvBpYndcqgzYizbiLMfNfoAf6 ffvrxMxW7pTVATckFaq/9zuHwGWxrxBxdsn3Ef9ckd2wUTlTUiwSOG3Y1JVTyDLL MPZ0ZzZmS6sclDc7VUV6OUGaVxZWHqYs5wO2l9s5asXr+CRYoFrCwAbs4NmuHTjB Kk6XRh4TVti4rA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudekiedgheehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpedujeevjeffjeevuddutedvkeeiueeitddvieelfeekveej udefgeeuvdejhfeuleenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhh vghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 1 Oct 2021 08:53:51 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 835282A07B8; Fri, 1 Oct 2021 09:53:48 -0300 (-03) Date: Fri, 1 Oct 2021 09:53:48 -0300 From: Alvaro Herrera To: Amit Kapila Cc: Robert Haas , PostgreSQL Hackers Subject: Re: pgsql: Document XLOG_INCLUDE_XID a little better Message-ID: <202110011253.mrkyl4rmokau@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021-Oct-01, Amit Kapila wrote: > AFAICS, there are two possibilities w.r.t global variables: (a) use > curinsert_flags which we are doing now, (b) another is to introduce a > new global variable, set it after we make the association, and then > reset it after we mark SubTransaction assigned and on error. I have > also thought of passing it via XLogCtlInsert but as that is shared by > different processes, it can be set by one process and be read by > another process which we don't want here. So, in my mind, curinsert_flags is a way for the high-level user of XLogInsert to pass info about the record being inserted to the low-level xloginsert.c infrastructure. In contrast, XLOG_INCLUDE_XID is being used solely within xloginsert.c, by one piece of low-level infrastructure to communicate to another piece of low-level infrastructure that some cleanup is needed. Nothing outside of xloginsert.c needs to know anything about XLOG_INCLUDE_XID, in contrast with the other bits that can be set by XLogSetRecordFlags. You could move the #define to xloginsert.c and everything would compile fine. Another tell-tale sign that things are not fitting right is that XLOG_INCLUDE_XID is not set via XLogSetRecordFlags, contrary the comment above those defines. (Aside: I wonder why do we have XLogSetRecordFlags at all -- I think we could just pass the other two flags via XLogBeginInsert). Regarding XLOG_INCLUDE_XID, I don't think replacing it with a bit in shared memory is a good idea, since it only applies to the insertion being carried out by the current process, right? I think a straight standalone variable (probably a static boolean in xloginsert.c) might be less confusing. ... so, reading the xact.c code again, TransactionState->assigned really means "whether the subXID-to-topXID association has been wal-logged", which is a completely different meaning from what the term 'assigned' means in all other comments in xact.c ... and I think the subroutine name MarkSubTransactionAssigned() is not a great choice either. -- Álvaro Herrera 39°49'30"S 73°17'W — https://www.EnterpriseDB.com/ "Nunca se desea ardientemente lo que solo se desea por razón" (F. Alexandre)