Out of curiosity. Do we still need the "LOCK TABLE acs_objects IN SHARE ROW EXCLUSIVE MODE" statement if we are running PG 8.2.3 and higher? Interestingly this command is now causing the deadlock, where in 8.1 it was supposed to prevent us from them.