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:
- Deactivated/Deleted all WPML plugins
- Install a fresh copy of WPML core plugin
- Repaired the wp_options table
- Installed remaining WPML plugins from https://example.com/wp-admin/plugin-install.php?tab=commercial
This is the technical support forum for WPML - the multilingual WordPress plugin.