Query Error ERROR: query failed: INSERT INTO `keys` (`name`, `value`) VALUES (?, ?) - Error: Duplicate entry ‘sixa’ for key ‘name’

hi @rickzimm, if you’re able, try reinstalling to confirm wasn’t a fluke, thanks.

I have made a clean install of openemr 6.0.0 on the server (+ new database). Still have to wait till a few apache and php settings are imported (after the server migration done by the provider to a new system, I’m not able to do those myself.)

First, after the provider’s migration, I will check if openemr works as it should be without the same issues as described above.

If it works as it suppose to be, I wil try to import the data from my operational openemr database into the clean database, and see what happens.

If anyone still have suggestions, please feel free …

Hi @sjpadgett and @brady.miller this is maybe something for the openemr developers:
After logging in go to: administration -> forms -> layout, select: demographics
In demographics , after a few minutes the following message was displayed: This page is not responding: openemr (wait or close).

My domain provider figured out that this only happens in the browsers: Edge and Mozilla Firefox.
However, in Chrome it’s working as it is supposed to be.

Still have the following error: Print screen error.pdf (82.6 KB)

Also the the following is still there: ERROR: query failed: INSERT INTO keys (name, value) VALUES (?, ?) Error: Duplicate entry ‘sixa’ for key ‘name’
Appears under the “settings for practice” the “healthinsurance companies and X12-partners”
Note: in menu Administration -> practice, in submenu only practice settings appears, not rules and alerts!

And, after 10 minutes, the following error appears when using patient finder:
DataTables warning: table id=pt_table - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1
And also when selecting other menus items it says: Site ID is missing from session data!

Can you help me out with this?

thx

hi @rickzimm, what customizations if any were made to the demographics layout?

Non, there are no modifications made.

OK, and this is version 6.0.0(2)?

Screenshot from 2021-07-15 07-46-09

also, any modifications to the codebase like this thread?

I’m using vs 6.0.0(2).

First, I made that configuration, however it didn’t worked out as it used to be in forms where extra keywords were added. I have restored the original files.

OK, you’re using edge browser? Have you cleared the cache?

In this case I use Firefox, Edge and Chrome I did clear the cache several times

OK, when you say you’ve checked the core demographics, have you compared the IDs in the Demographics layout


with the Name column in the patient_data table like in this phpmyadmin view?
Screenshot from 2021-07-15 09-37-01

I checked demographics with the demo version.

I will check also as mentioned above.

The following copied from my error log:
[Thu Jul 15 15:27:58.336768 2021] [fcgid:warn] [pid 7409:tid 140668190009088] [client 2a02:a45c:3bef:1:716f:4b2f:4c0c:b845:36538] mod_fcgid: stderr: SQL Error with statement:query failed: INSERT INTO keys (name, value) VALUES (?, ?)–Duplicate entry 'sixa' for key 'name'==>/var/www/vhosts/domeinname.nl/httpdocs/openemr/src/Common/Crypto/CryptoGen.php at 433:sqlStatementNoLog, referer: https://www.domeinname.nl/openemr/controller.php?practice_settings&pharmacy&action=list

Does this make the error a little clearer?

what if you comment out lines 19 and 21 of sites/default/config.php so the cryptogen isn’t called on these 2 array values? does that suppress the error in practice settings?

I did ## lines 19 and 21, the same error still exist …

A temporary workaround would be to replace the INSERT statement by :

  1. If the value of sixa needs to be updated -
INSERT INTO keys (name, value) VALUES (?,?)
  ON DUPLICATE KEY UPDATE value=?
** Will need to provide "value" twice to be replacing additional "?" **
  1. If logic requires current sixa to be retained -
INSERT IGNORE INTO keys (name, value) VALUES (?,?);
1 Like

@rickzimm
The issue here is the routine that queries keys table to check if the key exist is returning they don’t so, it tries to insert. I suspect the keys table is corrupt so try to run

  • CHECK TABLE `keys`;
  • ALTER TABLE `keys` ENGINE = InnoDB;
  • OPTIMIZE TABLE `keys`; This will really recreate and analyze instead
  • FLUSH TABLE `keys`;

btw: check your collations

1 Like

Hi @sjpadgett ,

I do not have the proper RELOAD privileges to run this in PHPmyAdmin, so I asked my provider to solve this, as soon as I have the information or right privileges from them I will get back to you.

What do I have to do for: check your collations?

BTW:
I installed a new (clean) openemr vs 6.0.0 (2), checked that everything worked as it is supposed to be, uploaded the (old) database from the openemr version which are giving the errors in the new openemr version, and replaced the correct keys (sixa and sixb) in the new openemr.
After logging in, in the new openemr version, the same errors still persist …
Maybe this will help you find the solution …

Hi @mdsupport,

where do I have to put those lines, in which file?

huh, something’s not making sense then, since if those are commented then the practice settings wouldn’t call the cryptogen function

From the error log, it looks like src/Common/Crypto/CryptoGen.php - line 433.
Disclaimer - Workaround till root cause is hunted down by the project angels.