Fix dropped object handling in pg_event_trigger_ddl_commands

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Fix dropped object handling in pg_event_trigger_ddl_commands

Sven Klemm-3
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Fix dropped object handling in pg_event_trigger_ddl_commands

Sven Klemm-3
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Fix dropped object handling in pg_event_trigger_ddl_commands

Álvaro Herrera
On 2021-Apr-25, Sven Klemm wrote:

> On Sun, Apr 18, 2021 at 2:12 PM Sven Klemm <[hidden email]> wrote:
> > when creating an event trigger for ddl_command_end that calls
> > pg_event_trigger_ddl_commands certain statements will cause the
> > trigger to fail with a cache lookup error. The error happens on
> > master, 13 and 12 I didnt test any previous versions.
> >
> > trg=# ALTER TABLE t ALTER COLUMN f1 SET DATA TYPE bigint, ALTER COLUMN
> > f1 DROP IDENTITY;
> > ERROR: XX000: cache lookup failed for relation 13476892
> > CONTEXT: PL/pgSQL function ddl_end() line 5 at FOR over SELECT rows
> > LOCATION: getRelationTypeDescription, objectaddress.c:4178
>
> Any opinions on the patch? Is this not worth the effort to fix or is
> there a better way to fix this?

Hello, I haven't looked at this but judging from the general shape of
function and error message, it seems clearly a bug that needs to be
fixed somehow.  I'll try to make time to look at it sometime soon, but I
have other bugs to investigate and fix, so it may be some time.

I fear your proposal of ignoring the object may be the best we can do,
but I don't like it much.

--
Álvaro Herrera                            39°49'30"S 73°17'W
"La verdad no siempre es bonita, pero el hambre de ella sí"


Reply | Threaded
Open this post in threaded view
|

Re: Fix dropped object handling in pg_event_trigger_ddl_commands

Aleksander Alekseev-2
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Fix dropped object handling in pg_event_trigger_ddl_commands

Michael Paquier-2
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Fix dropped object handling in pg_event_trigger_ddl_commands

Álvaro Herrera
On 2021-Jun-09, Michael Paquier wrote:

> On Mon, Jun 07, 2021 at 12:44:42PM +0300, Aleksander Alekseev wrote:
> > I confirm that the bug still exists in master (be57f216). The patch
> > fixes it and looks good to me. I changed the wording a little and
> > added a regression test. The updated patch is in the attachment. I
> > added this thread to the CF and updated the status to "Ready for
> > Committer".
>
> FWIW, that looks rather natural to me to me to just ignore the object
> if it has already been dropped here.  The same kind of rules apply to
> tables dropped  with DROP TABLE which would not show up as of
> pg_event_trigger_ddl_commands(), but one can get a list as of
> pg_event_trigger_dropped_objects().

Oh, that parallel didn't occur to me.  I agree it seems a useful
precedent.

> Alvaro, were you planning to look at that?  I have not looked at the
> patch in details.  

I have it on my list of things to look at, but it isn't priority.  If
you to mess with it, please be my guest.

> missing_ok is available in getObjectIdentity() only
> since v14, so this cannot be backpatched :/

Ooh, yeah, I forgot about that.  And that one was pretty invasive ...

I'm not sure if we can reasonably implement a fix for older releases.
I mean, it's a relatively easy test: do a syscache search for the object
or a catalog indexscan (easy to do with get_object_property_data-based
API), and if the object is gone, skip getObjectTypeDescription and
getObjectIdentity.  But maybe this is too much code to add to stable
releases ...

--
Álvaro Herrera       Valdivia, Chile


Reply | Threaded
Open this post in threaded view
|

Re: Fix dropped object handling in pg_event_trigger_ddl_commands

Michael Paquier-2
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Fix dropped object handling in pg_event_trigger_ddl_commands

Michael Paquier-2
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Fix dropped object handling in pg_event_trigger_ddl_commands

Aleksander Alekseev-2
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Fix dropped object handling in pg_event_trigger_ddl_commands

Michael Paquier-2
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Fix dropped object handling in pg_event_trigger_ddl_commands

Michael Paquier-2
CONTENTS DELETED
The author has deleted this message.