MySQL - Fix it so a lock isn't held unnecessarily.