Title: [Plugin: WP-UserOnline] WordPress database error Duplicate entry errors
Last modified: August 20, 2016

---

# [Plugin: WP-UserOnline] WordPress database error Duplicate entry errors

 *  [kuprosa](https://wordpress.org/support/users/metal450/)
 * (@metal450)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/plugin-wp-useronline-wordpress-database-error-duplicate-entry-errors-1/)
 * This plugin seems to be generating a large number of database errors (in error_log):
 * WordPress database error Duplicate entry ‘2010-10-06 06:35:31-xxx.xxx.xxx.xxx-
   Mozilla/4.0 (compatible;)’ for key ‘useronline_id’ for query INSERT INTO wp_useronline(
   user_type,user_id,user_name,user_ip,user_agent,page_title,page_url,referral) 
   VALUES (‘guest’,’0′,’Guest’,’xxx.xxx.xxx.xxx’,’Mozilla/4.0 (compatible;)’,’xxxxxx’,’/
   a-night-in-a-slovenian-prison’,”) made by require, require_once, include, get_header,
   locate_template, load_template, require_once, wp_head, do_action, call_user_func_array,
   UserOnline_Core->record
 * They don’t occur all the time, but they are fairly consistent – i.e. maybe a 
   few every day.
 * [http://wordpress.org/extend/plugins/wp-useronline/](http://wordpress.org/extend/plugins/wp-useronline/)

Viewing 11 replies - 16 through 26 (of 26 total)

[←](https://wordpress.org/support/topic/plugin-wp-useronline-wordpress-database-error-duplicate-entry-errors-1/?output_format=md)
[1](https://wordpress.org/support/topic/plugin-wp-useronline-wordpress-database-error-duplicate-entry-errors-1/?output_format=md)
2

 *  Thread Starter [kuprosa](https://wordpress.org/support/users/metal450/)
 * (@metal450)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/plugin-wp-useronline-wordpress-database-error-duplicate-entry-errors-1/page/2/#post-2479597)
 * Again: this particular bug comes from the fact that the insert query doesn’t 
   verify that the line which is being inserted doesn’t already exist. The Mingle
   version uses the exact same insert query, so the same bug will exist.
 * True that Analytics is good, and I use that too. But this plugin is called USER
   online. Analytics can’t tell you which USER is online, so it’s in no way a replacement
   for this plugin…
 *  [kamalh](https://wordpress.org/support/users/kamalh/)
 * (@kamalh)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/plugin-wp-useronline-wordpress-database-error-duplicate-entry-errors-1/page/2/#post-2479598)
 * Hmmm anyways all I can tell you is, I was using wp-useronline and the main bug
   that I found was the gibberish characters in place of the user online info.
 * But Mingle user online seems to be just perfect. My blogs are not multi-authored.
   Anyways what is the main problems you guys facing with the original plugin??
 *  Thread Starter [kuprosa](https://wordpress.org/support/users/metal450/)
 * (@metal450)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/plugin-wp-useronline-wordpress-database-error-duplicate-entry-errors-1/page/2/#post-2479599)
 * …It’s documented above. This thread has nothing to do with character encoding
   whatsoever.
 *  [kamalh](https://wordpress.org/support/users/kamalh/)
 * (@kamalh)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/plugin-wp-useronline-wordpress-database-error-duplicate-entry-errors-1/page/2/#post-2479600)
 * I hope that the developers of this plugin look it into all these problems some
   day and do something about it!
 *  Thread Starter [kuprosa](https://wordpress.org/support/users/metal450/)
 * (@metal450)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/plugin-wp-useronline-wordpress-database-error-duplicate-entry-errors-1/page/2/#post-2479601)
 * Plugins on WordPress.org are free and opensource. Developers contribute however
   much or little time they see fit, so if you’re anxious to get things fixed you
   should probably submit your own specific solutions/proposals (as I’ve done above)
   or offer to pay for their time.
 *  [kamalh](https://wordpress.org/support/users/kamalh/)
 * (@kamalh)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/plugin-wp-useronline-wordpress-database-error-duplicate-entry-errors-1/page/2/#post-2479602)
 * Paying the developers seems to be the best way to get things done.. I hope you
   find a solution to your problems as well..
 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/plugin-wp-useronline-wordpress-database-error-duplicate-entry-errors-1/page/2/#post-2479603)
 * The duplicate errors still don’t make any sense. The unique constraint looks 
   like this:
 *     ```
       UNIQUE KEY useronline_id ( timestamp, user_type, user_ip )
       ```
   
 * But, before the INSERT query, there’s another query that clears all records with
   the same user_ip:
 *     ```
       DELETE FROM $wpdb->useronline
       WHERE user_ip = %s
       OR timestamp < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL %d SECOND)
       ```
   
 * So, it’s theoretically impossible to trigger a unique error, since there would
   be no records with the same user_ip, let alone with an exact combination of user_ip
   + user_type + timestamp.
 * Could you paste the exact error text?
 *  Thread Starter [kuprosa](https://wordpress.org/support/users/metal450/)
 * (@metal450)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-useronline-wordpress-database-error-duplicate-entry-errors-1/page/2/#post-2479604)
 * >>Could you paste the exact error text?
 * One is copied in the first post above; unfortunately I deleted the most recent
   error_log, so if you need a new one I’d have to wait until it happens again. 
   It’s much less frequent now that the ip field was expanded, but it does still
   happen periodically.
 * >>But, before the INSERT query, there’s another query that clears all records
   with the same user_ip
 * Well, as mentioned it seems to happen when the server is severely lagging. It
   also nearly always occurs in “chunks” – i.e. it happens 20 times in a few seconds…
   and then not again for a week. So perhaps i.e. while the server is lagging it
   falls behind on queries or something. Which is why, if the check for duplicates
   were done within one single query (rather than two closely-spaced but separate
   queries), it should be completely and utterly impossible for it to happen.
 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-useronline-wordpress-database-error-duplicate-entry-errors-1/page/2/#post-2479605)
 * Ok, the [development version](http://downloads.wordpress.org/plugin/wp-useronline.zip)(
   2.82-beta2) uses REPLACE instead of INSERT.
 * Please try it out and report back.
 *  Thread Starter [kuprosa](https://wordpress.org/support/users/metal450/)
 * (@metal450)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-useronline-wordpress-database-error-duplicate-entry-errors-1/page/2/#post-2479606)
 * Just installed it and will let you know if that error pops up again – however,
   in doing a quick post-update test, I found something that’s definitely not right.
   Here’s what I did:
 * 1) Connect to a VPN, login to my WordPress site as User1 via Chrome, view Page1
   
   2) Disconnect from the VPN, login to my WordPress site as Admin via Firefox, 
   and view the “users online now” page.
 * Thus, I explicitly viewed a known page from a different browser and IP address
   than the admin who is checking users online. The current page for User1 was *
   not* Page1. Furthermore, I noticed that it showed a GoogleBot online on Page1.
   It looks like signals are getting crossed – you might want to run a similar test.
 *  Thread Starter [kuprosa](https://wordpress.org/support/users/metal450/)
 * (@metal450)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-useronline-wordpress-database-error-duplicate-entry-errors-1/page/2/#post-2479607)
 * Hang on – I just tried it a few more times and couldn’t get it to happen again.
   Strange, maybe it was a fluke – though I am pretty certain I did the test right
   the first time. Maybe just something leftover because I’d JUST updated/activated
   the plugin or something…

Viewing 11 replies - 16 through 26 (of 26 total)

[←](https://wordpress.org/support/topic/plugin-wp-useronline-wordpress-database-error-duplicate-entry-errors-1/?output_format=md)
[1](https://wordpress.org/support/topic/plugin-wp-useronline-wordpress-database-error-duplicate-entry-errors-1/?output_format=md)
2

The topic ‘[Plugin: WP-UserOnline] WordPress database error Duplicate entry errors’
is closed to new replies.

 * ![](https://ps.w.org/wp-useronline/assets/icon.svg?rev=978026)
 * [WP-UserOnline](https://wordpress.org/plugins/wp-useronline/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-useronline/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-useronline/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-useronline/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-useronline/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-useronline/reviews/)

 * 26 replies
 * 3 participants
 * Last reply from: [kuprosa](https://wordpress.org/support/users/metal450/)
 * Last activity: [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-useronline-wordpress-database-error-duplicate-entry-errors-1/page/2/#post-2479607)
 * Status: not resolved