OCSInventory-NG / OCSInventory-Server

Communication server of OCS Inventory
http://www.ocsinventory-ng.org/
GNU General Public License v2.0
344 stars 139 forks source link

Duplicate entry '2147483647' for key 'PRIMARY' at Software.pm (solved) #355

Closed pchamo closed 2 years ago

pchamo commented 2 years ago

General informations

Operating system : CentOS 7

Server informations

Perl version : v5.16.3 Mysql / Mariadb / Percona version : mysql-community-common-5.7.35

OCS Inventory informations

Ocs server version : 2.9.1

Problem's description

I'm having HTTP Error 500, with OCS_OPT_DBI_PRINT_ERROR enabled, like this:

DBD::mysql::st execute failed: Duplicate entry '2147483647' for key 'PRIMARY' at /usr/local/share/perl5/Apache/Ocsinventory/Server/Inventory/Software.pm line 59.

When that error message appears, it collapses the ocs server and the only way to restore the server is to drop de database, create a new one and to import the most recent backup. And it works again for some minutes or hours until that message error appears again. I did a SQL search using phpmyadmin and that 2147483647 value is not in ocs anywhere.

I didn't have issues like these with ocs agent 2.4.0. I updated most of the computers to ocs agent to 2.9.0.0. And afterwards downgraded to 2.4.0 but the issue was still there until I realized that the bug is caused because the ID column is type INT and in my case the max value for that type of integers was reached, so, I changed the type to BIGINT and that solved my issue.

Please, change the type of the primary key of the software table to BIGINT to avoid that others have the same nasty bug, if you consider that as the best solution.

wiltonsr commented 2 years ago

Hi @pchamo,

The table software already has ID with BIGINT, you could check here.

Lea9250 commented 2 years ago

Hi @pchamo,

The fix has been recently done on the ocsreports repository : on database creation the field was set to BIGINT but not on update.

Thank you for your report, Léa