jsha / blocktogether

Share your blocks and subscribe to others'
GNU General Public License v3.0
330 stars 68 forks source link

storeUser, called from stream.js, produces duplicate record errors #171

Closed jsha closed 9 years ago

jsha commented 9 years ago

There's a race condition in storeUser: first it tries to load a user from the DB if it exists; Otherwise it creates one. In low traffic this isn't an issue, but in stream.js often there are multiple very closely-spaced calls to storeUser for the same user.

Options:

jsha commented 9 years ago

Updated title to better reflect what happens when this occurs. MySQL generates an error because of a duplicate primary key (uid), which winds up in the logs. Harmless, but obscures other, real errors in the logs. So maybe one other approach: If there's an error from the sequelize save command, don't bother logging it, or log it at INFO or even DEBUG level.

jsha commented 9 years ago

Fixed.