Hello +/* + * GetForeignServerByNameLocked - look up a foreign server by name and lock it. + * + * The lock protects the server from concurrent deletion after resolving its + * name but before fetching its catalog tuple by OID. + */ +ForeignServer * +GetForeignServerByNameLocked(const char *srvname, LOCKMODE lockmode, + bool missing_ok)
Is this the right solution for a possibly backpatchable fix? It's a new public function, undocumented (GetForeignServerByName is mentioned in fdwhandler.sgml), and adds a circular dependency between foreign.h/c and objectaddress.h/c. + * The lock protects the server from concurrent deletion after resolving its + * name but before fetching its catalog tuple by OID. + */ Why do we have to lock for that? Isn't this a bug/issue with GetForeignServerByName that should be fixed? That currently it performs 2 syscache lookups, when 1 should be enough, and then we can't have any inconsistency.
