Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XvdhL-0003VR-EK for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Dec 2014 03:00:19 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XvdhK-0002dE-Uo for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Dec 2014 03:00:19 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XvdhK-0002ck-2C for pgsql-hackers@postgresql.org; Tue, 02 Dec 2014 03:00:18 +0000 Received: from tama500.ecl.ntt.co.jp ([129.60.39.148]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XvdhF-0002j1-15 for pgsql-hackers@postgresql.org; Tue, 02 Dec 2014 03:00:15 +0000 Received: from mfs6.rdh.ecl.ntt.co.jp (mfs6.rdh.ecl.ntt.co.jp [129.60.39.149]) by tama500.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id sB23036a023814; Tue, 2 Dec 2014 12:00:03 +0900 Received: from mfs6.rdh.ecl.ntt.co.jp (localhost.localdomain [127.0.0.1]) by mfs6.rdh.ecl.ntt.co.jp (Postfix) with ESMTP id BEDFFE00AC; Tue, 2 Dec 2014 12:00:03 +0900 (JST) Received: from imail3.m.ecl.ntt.co.jp (imail3.m.ecl.ntt.co.jp [129.60.5.248]) by mfs6.rdh.ecl.ntt.co.jp (Postfix) with ESMTP id B25CEE006D; Tue, 2 Dec 2014 12:00:03 +0900 (JST) Received: from [129.60.241.75] ([129.60.241.75]) by imail3.m.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id sB2302Gj024206; Tue, 2 Dec 2014 12:00:03 +0900 Message-ID: <547D2B1D.1080107@lab.ntt.co.jp> Date: Tue, 02 Dec 2014 11:59:41 +0900 From: Etsuro Fujita User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Ashutosh Bapat CC: Kyotaro HORIGUCHI , Heikki Linnakangas , Noah Misch , Shigeru Hanada , pgsql-hackers Subject: Re: inherit support for foreign tables References: <543D0261.6020803@lab.ntt.co.jp> <54461BEB.9000707@lab.ntt.co.jp> <5449EE98.1040704@lab.ntt.co.jp> <20141107.145713.169337282.horiguchi.kyotaro@lab.ntt.co.jp> <545CB4A2.1030303@lab.ntt.co.jp> <54645499.7050709@lab.ntt.co.jp> <5476FB4B.9060705@lab.ntt.co.jp> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org (2014/11/28 18:14), Ashutosh Bapat wrote: > On Thu, Nov 27, 2014 at 3:52 PM, Etsuro Fujita > > wrote: > Apart from the above, I noticed that the patch doesn't consider to > call ExplainForeignModify during EXPLAIN for an inherited > UPDATE/DELETE, as shown below (note that there are no UPDATE remote > queries displayed): > So, I'd like to modify explain.c to show those queries like this: > postgres=# explain verbose update parent set a = a * 2 where a = 5; > QUERY PLAN > ------------------------------__------------------------------__------------------------- > Update on public.parent (cost=0.00..280.77 rows=25 width=10) > -> Seq Scan on public.parent (cost=0.00..0.00 rows=1 width=10) > Output: (parent.a * 2), parent.ctid > Filter: (parent.a = 5) > Remote SQL: UPDATE public.mytable_1 SET a = $2 WHERE ctid = $1 > -> Foreign Scan on public.ft1 (cost=100.00..140.38 rows=12 > width=10) > Output: (ft1.a * 2), ft1.ctid > Remote SQL: SELECT a, ctid FROM public.mytable_1 WHERE ((a > = 5)) FOR UPDATE > Remote SQL: UPDATE public.mytable_2 SET a = $2 WHERE ctid = $1 > -> Foreign Scan on public.ft2 (cost=100.00..140.38 rows=12 > width=10) > Output: (ft2.a * 2), ft2.ctid > Remote SQL: SELECT a, ctid FROM public.mytable_2 WHERE ((a > = 5)) FOR UPDATE > (12 rows) > Two "remote SQL" under a single node would be confusing. Also the node > is labelled as "Foreign Scan". It would be confusing to show an "UPDATE" > command under this "scan" node. I thought this as an extention of the existing (ie, non-inherited) case (see the below example) to the inherited case. postgres=# explain verbose update ft1 set a = a * 2 where a = 5; QUERY PLAN ------------------------------------------------------------------------------------- Update on public.ft1 (cost=100.00..140.38 rows=12 width=10) Remote SQL: UPDATE public.mytable_1 SET a = $2 WHERE ctid = $1 -> Foreign Scan on public.ft1 (cost=100.00..140.38 rows=12 width=10) Output: (a * 2), ctid Remote SQL: SELECT a, ctid FROM public.mytable_1 WHERE ((a = 5)) FOR UPDATE (5 rows) I think we should show update commands somewhere for the inherited case as for the non-inherited case. Alternatives to this are welcome. > BTW, I was experimenting with DMLs being executed on multiple FDW server > under same transaction and found that the transactions may not be atomic > (and may be inconsistent), if one or more of the server fails to commit > while rest of them commit the transaction. The reason for this is, we do > not "rollback" the already "committed" changes to the foreign server, if > one or more of them fail to "commit" a transaction. With foreign tables > under inheritance hierarchy a single DML can span across multiple > servers and the result may not be atomic (and may be inconsistent). So, IIUC, even the transactions over the local and the *single* remote server are not guaranteed to be executed atomically in the current form. It is possible that the remote transaction succeeds and the local one fails, for example, resulting in data inconsistency between the local and the remote. > either we have to disable DMLs on an inheritance hierarchy which spans > multiple servers. OR make sure that such transactions follow 2PC norms. -1 for disabling update queries on such an inheritance hierarchy because I think we should leave that to the user's judgment. And I think 2PC is definitely a separate patch. Thanks, Best regards, Etsuro Fujita -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers