Re: User defined data types in Logical Replication

From: Dang Minh Huong <kakalot49(at)gmail(dot)com>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: Huong Dangminh <huo-dangminh(at)ys(dot)jp(dot)nec(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Hiroshi Yanagisawa <hir-yanagisawa(at)ut(dot)jp(dot)nec(dot)com>
Subject: Re: User defined data types in Logical Replication
Date: 2017-12-06 15:23:52
Message-ID: 0ec082ce-8c06-bfdb-788c-13e15ba0ba17@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Sawada-san,

Sorry for my late response.

On 2017/12/05 0:11, Masahiko Sawada wrote:
>> There is one more case that user-defined data type is not supported in Logical Replication.
>> That is when remote data type's name does not exist in SUBSCRIBE.
>>
>> In relation.c:logicalrep_typmap_gettypname
>> We search OID in syscache by remote's data type name and mapping it, if it does not exist in syscache
>> We will be faced with the bellow error.
>>
>> if (!OidIsValid(entry->typoid))
>> ereport(ERROR,
>> (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
>> errmsg("data type \"%s.%s\" required for logical replication does not exist",
>> entry->nspname, entry->typname)));
>>
>> I think, it is not necessary to check typoid here in order to avoid above case, is that right?
> I think it's not right. We should end up with an error in the case
> where the same type name doesn't exist on subscriber. With your
> proposed patch, logicalrep_typmap_gettypname() can return an invalid
> string (entry->typname) in that case, which can be a cause of SEGV.
Thanks, I think you are right.
# I thought that entry->typname was received from walsender, and it is
already be qualified in logicalrep_write_typ.
# But we also need check it in subscriber, because it could be lost info
in transmission.
Also we do not need to fix for the case above too, because user can
change type name by ALTER TYPE statement.
I attached the patch, which based on your patch with a bit of modified
messages.

---
Thanks and best regards,
Dang Minh Huong

Attachment Content-Type Size
fix_slot_store_error_callback_V3.patch text/plain 5.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-12-06 15:29:16 Re: pgsql: Support Parallel Append plan nodes.
Previous Message Tom Lane 2017-12-06 15:16:34 Re: ALTER TABLE ADD COLUMN fast default