Nagaura-san,
The client-side tcp_user_timeout patch looks good.
The server-side tcp_user_timeout patch needs fixing the following:
(1)
+ GUC_UNIT_MS | GUC_NOT_IN_SAMPLE
+ 12000, 0, INT_MAX,
GUC_NOT_IN_SAMPLE should be removed because the parameter appears in postgresql.conf.sample.
The default value should be 0, not 12000.
(2)
Now that you've changed show_tcp_usertimeout() to use pq_gettcpusertimeout(), you need to modify
pq_settcpusertimeout();just immitate pq_setkeepalivesidle(). Otherwise, SHOW would display a wrong value.
Regards
Takayuki Tsunakawa