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 1i0MO6-0003SQ-Iv for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Aug 2019 08:54:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i0MO4-0002CM-KY for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Aug 2019 08:54:36 +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 1i0MO4-00029Y-7H for pgsql-hackers@lists.postgresql.org; Wed, 21 Aug 2019 08:54:36 +0000 Received: from cyclops.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i0MO1-0008V6-28 for pgsql-hackers@postgresql.org; Wed, 21 Aug 2019 08:54:35 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 446C421C2448; Wed, 21 Aug 2019 11:54:31 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from [192.168.27.200] (gw.postgrespro.ru [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 9B44E21C2445; Wed, 21 Aug 2019 11:54:30 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1566377671; bh=EIUw5RW/CSgujp19JBnFS50NX50kEbC2VjiZjik+VEI=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=W2wyzNhavqrbE1AKz096+kYmeNGf5/lM9/QCttcX1uzge2LGYmitklvYShqLEA4cC 0myTHMg6Sz3SBURJIZgJc7M9sTMuZJSWWYAvy487sbGnIH45SnFHCsJKsQPKbwgZzd V4KnqaF2kYpIF1G9TKu2b9dxJsEb7d3hpWMFbtwg= Subject: Re: Global temporary tables To: Pavel Stehule Cc: Craig Ringer , PostgreSQL Hackers References: <73954ab7-44d3-b37b-81a3-69bdcbb446f7@postgrespro.ru> <758e5293-3ccd-3a6a-8464-6373bb441994@postgrespro.ru> <0bc85c39-67a2-3bb4-d6fc-bf78862147a5@postgrespro.ru> <0e2cf77c-a67f-0bdc-fb4f-844c166d71de@postgrespro.ru> <202c1a08-463d-3e8b-a5be-99f59df4e9f9@postgrespro.ru> From: Konstantin Knizhnik Message-ID: <2d51d648-87f9-3480-e8d9-0279e8f8cd53@postgrespro.ru> Date: Wed, 21 Aug 2019 11:54:29 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------0F5FC3A79C76D2F55928D27B" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------0F5FC3A79C76D2F55928D27B Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 20.08.2019 20:01, Pavel Stehule wrote: > Another solution is wait on ZHeap storage and replica can to have own > UNDO log. > >> > I thought about implementation of special table access method for > temporary tables. > > > +1 > Unfortunately implementing special table access method for temporary tables doesn't solve all problems. XID generation is not part of table access methods. So we still need to assign some XID to write transaction at replica which will not conflict with XIDs received from master. Actually only global temp tables can be updated at replica and so assigned XIDs can be stored only in tuples of such relations. But still I am not sure that we can use arbitrary XID for such transactions at replica. Also I upset by amount of functionality which has to be reimplemented for global temp tables if we really want to provide access method for them: 1. CLOG 2. vacuum 3. MVCC visibility And still it is not possible to encapsulate all changes need to support writes to temp tables at replica inside table access method. XID assignment, transaction commit and abort, subtransactions - all this places need to be patched. -- Konstantin Knizhnik Postgres Professional: http://www.postgrespro.com The Russian Postgres Company --------------0F5FC3A79C76D2F55928D27B Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

On 20.08.2019 20:01, Pavel Stehule wrote:
Another solution is wait on ZHeap storage and replica can to have own UNDO log.

I thought about implementation of special table access method for temporary tables.

+1
 

Unfortunately implementing special table access method for temporary tables doesn't solve all problems.
XID generation is not part of table access methods.
So we still need to assign some XID to write transaction at replica which will not conflict with XIDs received from master.
Actually only global temp tables can be updated at replica and so assigned XIDs can be stored only in tuples of such relations.
But still I am not sure that we can use arbitrary XID for such transactions at replica.

Also I upset by amount of functionality which has to be reimplemented for global temp tables if we really want to provide access method for them:

1. CLOG
2. vacuum
3. MVCC visibility

And still it is not possible to encapsulate all changes need to support writes to temp tables at replica inside table access method.
XID assignment, transaction commit and abort, subtransactions - all this places need to be patched.



-- 
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company 
--------------0F5FC3A79C76D2F55928D27B--