piesync / billbo

Easy to use billing service for Stripe with VAT support
MIT License
73 stars 3 forks source link

Simultaneous invoice number increment #37

Closed challengee closed 10 years ago

challengee commented 10 years ago

It's possible to have the same sequence number now. If we keep working with puma with one worker and 20 threads, we can solve this with a mutex. If we scale to multiple process, we need to solve this another way.

Suggestions?

mohawke commented 10 years ago

make the invoice number a unique field in the db, if we can't save with a certain number, increment that number and use that one?

challengee commented 10 years ago

yep then we need to figure out how to set this constraint in postgres :)