The threading bug appears when a duration is set for pgbench tests. Instead of a duration, if a number of xacts is set, this error doesn't happen.
If i understood the problem well, when the alarm signal comes, all the threads have to disconnect even the ones looking for a setshell parameter at this moment, creating the thread error: setshell: error getting parameter Client 0 aborted in state 1. Execution of meta-command failed. I am trying to find an elegant way to solve this, but I can't figure out yet how to deal with this error as it looks tricky.