"Fujii Masao" <fujii(dot)masao(at)oss(dot)ntt(dot)co(dot)jp> writes:
> I found an error that tcp_keepalive doesn't work.
You seem to have a misunderstanding of what tcp_keepalive is for. It
does not kill a backend that is in the midst of a query. A backend will
terminate when it is waiting for a client command and it sees that the
connection has been lost --- which is what a TCP timeout will cause to
happen. But your example backends are not waiting for client commands.
If you want backends to abort live queries before they finish, use
statement_timeout.
regards, tom lane