Yes, mongodb has no transactions and will not lock the table. The process from querying the number to writing is not atomic, so high concurrency will inevitably cause problems. It is recommended to modify the data and query interfaces to adapt to some mongodb atomic operations, such as generating red envelopes first, and then using findAndModify to query and synchronously modify the red envelope status when grabbing red envelopes.
Yes, mongodb has no transactions and will not lock the table. The process from querying the number to writing is not atomic, so high concurrency will inevitably cause problems.
It is recommended to modify the data and query interfaces to adapt to some mongodb atomic operations, such as generating red envelopes first, and then using findAndModify to query and synchronously modify the red envelope status when grabbing red envelopes.
Use findAndModify()