deployd / deployd

a toolkit for building realtime APIs
http://www.deployd.com
4.98k stars 660 forks source link

Race condition when inserting an object in DB #653

Closed NicolasRitouet closed 8 years ago

NicolasRitouet commented 8 years ago

With dpd-fileupload, you can upload many files within the same request. With node > 4.1 it leads to the error E11000: duplicate key error The problem is located in this function: https://github.com/deployd/deployd/blob/master/lib/db.js#L288 The variable object on line 293 is not the right one, it's using the latest given in this function due to the different scope. To fix it, we need to pass the right object all the way to the insert.

andreialecu commented 8 years ago

Not sure I follow this one. There is no loop here, this shouldn't be an issue. Could you provide a repro?

hjanuschka commented 8 years ago

i think this can be closed as dpd-fileupload now inerhits from collection wich should actually fix the E11000 (atleast on my side i can confirm that using the current master of dpd-fileupload fixes the issue)

@andreialecu , @NicolasRitouet