Re: Something broken around FDW connection close

From: Etsuro Fujita <fujita(dot)etsuro(at)lab(dot)ntt(dot)co(dot)jp>
To: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Something broken around FDW connection close
Date: 2017-03-31 03:32:39
Message-ID: f14ace82-d77e-f1fd-e313-f07df2c10a1b@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2017/03/31 8:28, David Rowley wrote:
> create table t (a int, b int);
> insert into t1 select x/100,x/100 from generate_series(1,100000) x;
> create extension if not exists postgres_fdw;
> create server test_server foreign data wrapper postgres_fdw options
> (host 'localhost', port '5432', dbname 'postgres');
> create foreign table ft_t (a int,b int) server test_server;
> select 'create user mapping for current_user server test_server
> options(user ''' || current_user || ''');';
> \gexec
> select count(*) from pg_stat_Activity; -- > 6
> analyze ft_t;
> ERROR: could not connect to server "test_server"
> DETAIL: FATAL: sorry, too many clients already
> CONTEXT: Remote SQL command: DECLARE c1 CURSOR FOR SELECT a, b FROM
> public.ft_t
> Remote SQL command: SELECT a, b FROM public.ft_t
> Remote SQL command: SELECT a, b FROM public.ft_t
> Remote SQL command: SELECT a, b FROM public.ft_t
> (lots of these)
>
> select count(*) from pg_stat_Activity; --> 105
>
> I've not had a moment to check into what's going on.

IIUC, I think the cause would be that since the foreign table ft_t is
considered to be still foreign on the foreign server, which is actually
the same server, postgres_fdw recursively repeats the loopback access to
ft_t. (So, the same thing would happen for something like: select *
from ft_t.) If the analysis is right, ISTM that it's the user's fault.

Best regards,
Etsuro Fujita

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dmitry Dolgov 2017-03-31 03:43:01 Re: [PATCH] few fts functions for jsonb
Previous Message Michael Paquier 2017-03-31 03:28:40 Re: Variable substitution in psql backtick expansion