Queue: Add protection for failed insert that would return incorrect LAST_INSERT_ID