Skip to content

Commit

Permalink
Use correct connection for cancellation in frontend's parallel slots
Browse files Browse the repository at this point in the history
While waiting for slots to become available in wait_on_slots() in
parallel_slot.c, the cancellation always relied on the first connection
in the set to do the job.  This could cause problems when this slot's
socket is gone as PQgetCancel() would return NULL in this case.  Rather
than always using the first connection, this changes the logic to use
the first valid connection for the cancellation.

Author: Ranier Vilela
Reviewed-by: Justin Pryzby
Discussion: https://postgr.es/m/CAEudQAokk1h_pUwGXsYS4oVOuf35s1O2o3TXGHpV8=AWikvgHA@mail.gmail.com
Backpatch-through: 14
  • Loading branch information
michaelpq committed Aug 27, 2022
1 parent 28d351c commit aeec353
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/fe_utils/parallel_slot.c
Expand Up @@ -237,7 +237,7 @@ wait_on_slots(ParallelSlotArray *sa)
if (cancelconn == NULL)
return false;

SetCancelConn(sa->slots->connection);
SetCancelConn(cancelconn);
i = select_loop(maxFd, &slotset);
ResetCancelConn();

Expand Down

0 comments on commit aeec353

Please sign in to comment.