I test the V4 patch and found the backend does't process SIGINT while it's in secure_read. And it seems not a good choice to report ERROR during secure_read, which will turns into FATAL "terminating connection because protocol synchronization was lost".
It might be much easier to terminate the backend rather than cancel the backend just like idle_in_transaction_session_timeout and idle_session_timeout did. But the name of the GUC might be transaction_session_timeout. And what about 2PC transaction? The hanging 2PC transaction also hurts server a lot. It’s active transaction but not active backend. Can we cancel the 2PC transaction and how we cancel it. -- Yuhang Qiu