Collection Locking

I have customers waiting to talk to CSRs, and each CSR will click on a button on UI to get the next customer (longest waiting). I want to avoid race condition here, means no two CSR should be assigned to same customer waiting their turn on the line.

I am thinking to use findAndModify of MongoDB, but will that solve the issue?

There is a collection “CustomerSessions”, in which a CSR will be assigned for each Customer.

That sounds like an excellent way to do this. :slight_smile:

Do your “find” on oldest, unassigned ticket, and your “modify” to assign. This command is atomic and will work even in multi-server Meteor applications.