I am now seeing another phenominom of hanging connections. They are
showing 'UPDATE' status in process list.
(gdb) bt
#0 0x00007f783f79d4f7 in semop () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00000000005f97d3 in PGSemaphoreLock ()
#2 0x0000000000638153 in LWLockAcquire ()
#3 0x00000000004a9239 in ginStepRight ()
#4 0x00000000004a9c61 in ginFindLeafPage ()
#5 0x00000000004a8377 in ginInsertItemPointers ()
#6 0x00000000004a4548 in ginEntryInsert ()
#7 0x00000000004ae687 in ginInsertCleanup ()
#8 0x00000000004af3d6 in ginHeapTupleFastInsert ()
#9 0x00000000004a4ab1 in gininsert ()
#10 0x0000000000709b15 in FunctionCall6Coll ()
#11 0x000000000047b6b7 in index_insert ()
#12 0x000000000057f475 in ExecInsertIndexTuples ()
#13 0x000000000058bf07 in ExecModifyTable ()
#14 0x00000000005766e3 in ExecProcNode ()
#15 0x0000000000575ad4 in standard_ExecutorRun ()
#16 0x000000000064718f in ProcessQuery ()
#17 0x00000000006473b7 in PortalRunMulti ()
#18 0x0000000000647e8a in PortalRun ()
#19 0x0000000000645160 in PostgresMain ()
#20 0x000000000060459e in ServerLoop ()
#21 0x00000000006053bc in PostmasterMain ()
#22 0x00000000005a686b in main ()
(gdb) q
This connection can not be killed by pg_cancel_backend nor
pg_terminate_backend. It just hangs there and does not respond to normal
kill command. I had to kill -9 the process to terminate whole
postgresql instance. What happened there and how can I kill these
connections safely?