@straceX Classic race condition problems. I think the fix is a single atomic SQL update, UPDATE tickets SET q=q-1 WHERE q>0. By collapsing the read and write into one indivisible operation, the database guarantees only one transaction can succeed , everyone else gets a sold-out message.