• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Future fix SQL Error When Following User

digitalpoint

Well-known member
#1
It's really rare (maybe like once every few days), but I see duplicate entry errors show up in our server log once in awhile when someone tries to follow someone.

Not really sure how to replicate it... I've tried double clicking follow really fast, etc. and I know there's code that checks if they are already following before it tries to follow them, but for whatever reason there's a case where that check fails when it shouldn't somehow.

We aren't using any custom database adapter, no master/slave setup, no custom datawriters or models that would affect it.

Maybe a good idea for it to be an INSERT IGNORE in this case?

upload_2013-8-13_14-27-19.png
 

Mike

XenForo developer
Staff member
#3
It's generally a race condition.

As we're using the datawriter here, it's not trivial to flip to an insert ignore. This isn't something I'd want to do as part of 1.2 as it changes APIs a bit, but it may be an option to choose an insert/update ignore in the DW and detect it in the save (stopping post save/returning false). I think we might need to explicitly opt into it as it could make the insert fail even without any errors after preSave() (unless we then log it as a duplicate record error).