BUG/MEDIUM: connections: Hold the lock when wanting to kill a connection.
authorOlivier Houchard <cognet@ci0.org>
Mon, 30 Dec 2019 17:15:40 +0000 (18:15 +0100)
committerOlivier Houchard <cognet@ci0.org>
Mon, 30 Dec 2019 17:18:28 +0000 (18:18 +0100)
commit140237471e408736bb7162e68c572c710a66a526
treed1acba2fa6f5dce533bf522ac84ebc222429b8f7
parent37d7897aafc412f3c4a4a68a1dccbd6b5d6cb180
BUG/MEDIUM: connections: Hold the lock when wanting to kill a connection.

In connect_server(), when we decide we want to kill the connection of
another thread because there are too many idle connections, hold the
toremove_lock of the corresponding thread, othervise, there's a small race
condition where we could try to add the connection to the toremove_connections
list while it has already been free'd.

This should be backported to 2.0 and 2.1.
src/backend.c