Fix race condition in setQueryTimeout

• Guards against race condition that could cancel the next executed after a query that issued a query timeout cancellation