This thread is resolved. Here is a description of the problem and solution.

Problem: WordPress database error Duplicate entry '504167' for key 'PRIMARY'

Solution: The issue was happening as wp_options table needed repairing, so to fix the issue, we did the following steps:

  1. Deactivated/Deleted all WPML plugins
  2. Install a fresh copy of WPML core plugin
  3. Repaired the wp_options table
  4. Installed remaining WPML plugins from

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 1 reply, has 1 voice.

Last updated by vadimP 9 months, 3 weeks ago.

Assigned support staff: Shekhar Bhandari.

Author Posts
August 8, 2019 at 9:42 am


I am trying to:

Do anything related to database - update plugins, add texts...

Link to a page where the issue can be seen:

error.log on server

I expected to see:

no errors

Instead, I got:

broken database with message in log

WordPress database error Duplicate entry '504167' for key 'PRIMARY' for query INSERT INTO `wp_options` (`option_name`, `option_value`, `autoload`) VALUES ('_transient_wpml_st_upgrade_in_progress', '1', 'no') ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`) made by require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('plugins_loaded'), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, SitePress->init, do_action('wpml_loaded'), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, wpml_tm_load, WPML_Translation_Management->load, do_action('wpml_tm_loaded'), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, WPML_String_Translation->load, WPML_ST_Upgrade->run, WPML_ST_Upgrade->run_front_end, WPML_ST_Upgrade->maybe_run, WPML_ST_Upgrade->set_upgrade_in_progress, set_transient, add_option

August 8, 2019 at 10:44 am
August 12, 2019 at 9:27 am #4379631


My issue is resolved now. Thank you!