As we can see in the OOPS, we timeout because a few queries are repeated almost 400 times each. These queries are issued by IPerson.getSubTeams() and IPerson.getSuperTeams(), which are called by _cleanTeamParticipation(), which is, in turn, called by ITeamMembership.setStatus().
Since the act of declining a membership invitation is not actually deactivating an active membership we shouldn't need to call _cleanTeamParticipation(), so that'd be one way to avoid the timeouts.
We'd still need to find out why the methods are being called so many times, though.
As we can see in the OOPS, we timeout because a few queries are repeated almost 400 times each. These queries are issued by IPerson. getSubTeams( ) and IPerson. getSuperTeams( ), which are called by _cleanTeamParti cipation( ), which is, in turn, called by ITeamMembership .setStatus( ).
Since the act of declining a membership invitation is not actually deactivating an active membership we shouldn't need to call _cleanTeamParti cipation( ), so that'd be one way to avoid the timeouts.
We'd still need to find out why the methods are being called so many times, though.