learning-unlimited/ESP-Website — pull request #292 by pricem (2012-03-12 14:34:59+00:00)
Title: Concurrency bug fixes for dbmail cron job

Stanford ESP had some issues lately with people receiving multiple e-mails when sent through the communications panel. I believe this accidental spam was caused by multiple dbmail_cron.py processes running concurrently (these are run by cron every minute). Our code looks like it wasn't designed for concurrency; while it does mark messages as sent before sending any, it may have been possible (with thousands of pending messages and the server busy) for a duplicate process to come up during this window. This commit series tries to fix that by making it impossible for concurrently running processes to send e-mails for the same message requests. There may also be issues with sending e-mail to class lists (e.g. X102-students@somewhere.learningu.org) but I haven't investigated yet.