I have not been able to test this (as the issue occurs intermittently), but this should fix the issue. I guess the true and correct way of fixing this would be to find out why this occurs in the first place, but the "ON DUPLICATE KEY UPDATE" should fix the issue regardless.
As the original issue was closed as not a core bug and a 3rd party extension issue. I'm going to close this.