pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp>
To: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
Cc: Luis Carril <luis.carril@swarm64.com>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Cc: PG Bug reporting form <noreply@postgresql.org>
Subject: Re: BUG #15552: Unexpected error in COPY to a foreign table in a transaction
Date: Tue, 18 Dec 2018 21:48:59 +0900
Message-ID: <5C18ECBB.2000507@lab.ntt.co.jp> (raw)
In-Reply-To: <30718b48-8020-329a-c6f0-74e1222e5283@lab.ntt.co.jp>
References: <15552-c64aa14c5c22f63c@postgresql.org>
	<8e82d10d-cc16-eed4-7634-3654f59d8053@lab.ntt.co.jp>
	<LEJPR01MB00109D0BECB8A961074A7CAFE7BC0@LEJPR01MB0010.DEUPRD01.PROD.OUTLOOK.DE>
	<30718b48-8020-329a-c6f0-74e1222e5283@lab.ntt.co.jp>

Hi Luis and Amit,

Thanks for the report, Luis!  Thanks for the discussion, Amit!

(2018/12/18 12:24), Amit Langote wrote:
> On 2018/12/17 22:12, Luis Carril wrote:
>>> heap_sync should only be called for relations that actually have files to
>>> sync, which isn't true for foreign tables.  So, a simple relkind check
>>> before calling heap_sync() in CopyFrom would suffice I think.  Although,
>>> we might also need such a check higher up in CopyFrom where some
>>> optimizations that are specific to "heap" relations are enabled.  For
>>> example, this piece of code:
>>
>>    thanks for the input, so it seems that is enough with adding the check as you suggested:
>>
>>      if (cstate->rel->rd_rel->relkind != RELKIND_PARTITIONED_TABLE&&
>>          cstate->rel->rd_rel->relkind != RELKIND_FOREIGN_TABLE&&
>>          (cstate->rel->rd_createSubid != InvalidSubTransactionId ||
>>           cstate->rel->rd_newRelfilenodeSubid != InvalidSubTransactionId))
>>      {
>>          hi_options |= HEAP_INSERT_SKIP_FSM;
>>          if (!XLogIsNeeded())
>>              hi_options |= HEAP_INSERT_SKIP_WAL;
>>      }
>
> I think that would do the trick.

I think so too.

FDWs would not look at heap_insert options, so another option would be 
to 1) leave that options as-is for foreign tables and 2) if the target 
is a foreign table, just skip heap_sync at the bottom of CopyFrom, or 
just return without doing anything in heap_sync.

Best regards,
Etsuro Fujita





view thread (37+ messages)  latest in thread

Message-ID: <5C18ECBB.2000507@lab.ntt.co.jp>
Permalink:  ../5C18ECBB.2000507@lab.ntt.co.jp/
Also on:    postgresql.org/message-id/5C18ECBB.2000507@lab.ntt.co.jp

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: fujita.etsuro@lab.ntt.co.jp, Langote_Amit_f8@lab.ntt.co.jp, luis.carril@swarm64.com, pgsql-bugs@lists.postgresql.org, noreply@postgresql.org
  Subject: Re: BUG #15552: Unexpected error in COPY to a foreign table in a transaction
  In-Reply-To: <5C18ECBB.2000507@lab.ntt.co.jp>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox