glpi icon indicating copy to clipboard operation
glpi copied to clipboard

Entity transfer MySQL query error: Duplicate entry

Open FelipeBasilio1991 opened this issue 7 months ago • 21 comments

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • [x] I have searched the existing issues

Version

11.0.0.BETA6

Bug description

Hello,

I'm encountering an error when trying to transfer some computers from the root entity to a sub-entity.

The error occurs when I perform the transfer with all items retained so that the data goes to the sub-entity.

I'm using version 11.0.0beta6

Relevant log output

[2025-07-09 12:19:01] glpi.ERROR:   *** Caught RuntimeException: MySQL query error: Duplicate entry 'Computer-39818-329651' for key 'glpi_items_softwareversions.unicity' (1062) in SQL query "UPDATE `glpi_items_softwareversions` SET `softwareversions_id` = '329651' WHERE `id` = '11666053'".
  Backtrace :
  ./src/DBmysql.php:369                              
  ./src/DBmysql.php:1430                             DBmysql->doQuery()
  ./src/Transfer.php:1744                            DBmysql->update()
  ./src/Transfer.php:1304                            Transfer->transferItemSoftwares()
  ./src/Transfer.php:250                             Transfer->transferItem()
  ./front/transfer.action.php:51                     Transfer->moveItems()
  ...Glpi/Controller/LegacyFileLoadController.php:59 require()
  ./vendor/symfony/http-kernel/HttpKernel.php:181    Glpi\Controller\LegacyFileLoadController->__invoke()
  ./vendor/symfony/http-kernel/HttpKernel.php:76     Symfony\Component\HttpKernel\HttpKernel->handleRaw()
  ./vendor/symfony/http-kernel/Kernel.php:197        Symfony\Component\HttpKernel\HttpKernel->handle()
  ./public/index.php:70                              Symfony\Component\HttpKernel\Kernel->handle()

Page URL

No response

Steps To reproduce

No response

Your GLPI setup information

No response

Anything else?

No response

FelipeBasilio1991 avatar Jul 09 '25 11:07 FelipeBasilio1991

Please try with latest beta, or even better the latest main branch nightly build.

trasher avatar Jul 09 '25 12:07 trasher

I updated to the version available in the nightly build ( main-2cd342b.tar.gz ). I tried again and the same error persists when trying to transfer the asset.

[2025-07-09 14:15:55] glpi.ERROR: *** Caught RuntimeException: MySQL query error: Duplicate entry 'Computer-39818-329651' for key 'glpi_items_softwareversions.unicity' (1062) in SQL query "UPDATE glpi_items_softwareversions SET softwareversions_id = '329651' WHERE id = '11666053'". Backtrace : ./src/DBmysql.php:369
./src/DBmysql.php:1430 DBmysql->doQuery() ./src/Transfer.php:1744 DBmysql->update() ./src/Transfer.php:1304 Transfer->transferItemSoftwares() ./src/Transfer.php:250 Transfer->transferItem() ./front/transfer.action.php:51 Transfer->moveItems() ...Glpi/Controller/LegacyFileLoadController.php:59 require() ./vendor/symfony/http-kernel/HttpKernel.php:181 Glpi\Controller\LegacyFileLoadController->__invoke() ./vendor/symfony/http-kernel/HttpKernel.php:76 Symfony\Component\HttpKernel\HttpKernel->handleRaw() ./vendor/symfony/http-kernel/Kernel.php:197 Symfony\Component\HttpKernel\HttpKernel->handle() ./public/index.php:70 Symfony\Component\HttpKernel\Kernel->handle()

FelipeBasilio1991 avatar Jul 09 '25 13:07 FelipeBasilio1991

OK, indeed the error is the same. Do you know if this error already exists with GLPI v10? It may be related to some existing data; maybe this is already broken with latest stable. In that case, we need to find a way to reproduce and add a specific case in our tests suite.

trasher avatar Jul 09 '25 13:07 trasher

OK, indeed the error is the same. Do you know if this error already exists with GLPI v10? It may be related to some existing data; maybe this is already broken with latest stable. In that case, we need to find a way to reproduce and add a specific case in our tests suite.

I have never used version 10. Since I started using GLPI I have been using the development version GLPI.11, in fact this error started when I updated to beta version 6.

FelipeBasilio1991 avatar Jul 09 '25 13:07 FelipeBasilio1991

OK, indeed the error is the same. Do you know if this error already exists with GLPI v10? It may be related to some existing data; maybe this is already broken with latest stable. In that case, we need to find a way to reproduce and add a specific case in our tests suite.

I have never used version 10. Since I started using GLPI I have been using the development version GLPI.11, in fact this error started when I updated to beta version 6.

GLPI: 11.0.0-dev ( => /var/www/html/glpi) Installation mode: TARBALL Current language: pt_PT

FelipeBasilio1991 avatar Jul 09 '25 13:07 FelipeBasilio1991

An update. When enabled, the inventory runs fine if the software option is not selected. However, if I enable the software option, the server reaches almost 100% CPU utilization, but does not generate any errors. Perhaps the error is related.

FelipeBasilio1991 avatar Jul 09 '25 14:07 FelipeBasilio1991

I confirm the issue. I cloned a Computer I had with a ton of software (from GLPI Agent but that doesn't seem relevant) and then tried doing a "complete" transfer from the root entity to a child entity.

cconard96 avatar Jul 14 '25 23:07 cconard96

This issue already exists on 10.0 versions

trasher avatar Sep 26 '25 07:09 trasher

I have a similar issue with tickets. Transferring between entities, similar to computers, also doesn't work. @cconard96, can you test it? Thanks

rjmontenegro avatar Oct 20 '25 14:10 rjmontenegro

I have the same error when transferring a computer from a parent entity to a child entity. As a temporary workaround, I unchecked the “Keep software” option during the transfer so that it would work.

Image

igorvisi avatar Nov 03 '25 06:11 igorvisi

Same error

teopost avatar Nov 11 '25 10:11 teopost

This looks like a pretty serious error. It seems that transferring objects between entities no longer works in version 11. It used to work in version 10.

I get this error:

[2025-11-12 18:11:41] glpi.ERROR:   *** Caught RuntimeException: MySQL query error: Duplicate entry 'Computer-30-7156' for key 'unicity' (1062) in SQL query "UPDATE `glpi_items_softwarever
sions` SET `softwareversions_id` = '7156' WHERE `id` = '15371'".
  Backtrace :
  ./src/DBmysql.php:371
  ./src/DBmysql.php:1446DBmysql->doQuery()
  ./src/Transfer.php:1708DBmysql->update()
  ./src/Transfer.php:1271Transfer->transferItemSoftwares()
  ./src/Transfer.php:246Transfer->transferItem()
  ./front/transfer.action.php:51Transfer->moveItems()
  ...Glpi/Controller/LegacyFileLoadController.php:64 require()
  ./vendor/symfony/http-kernel/HttpKernel.php:181    Glpi\Controller\LegacyFileLoadController->__invoke()
  ./vendor/symfony/http-kernel/HttpKernel.php:76     Symfony\Component\HttpKernel\HttpKernel->handleRaw()
  ./vendor/symfony/http-kernel/Kernel.php:197Symfony\Component\HttpKernel\HttpKernel->handle()
  ./public/index.php:70Symfony\Component\HttpKernel\Kernel->handle()

How can I fix this issue?

teopost avatar Nov 12 '25 17:11 teopost

#22019 should solve the issue. Take care of testing out of your productions environments.

trasher avatar Nov 21 '25 06:11 trasher

#22019 should solve the issue. Take care of testing out of your productions environments.

Well, I've closed it; I'm not sure this is a correct fix. You'd probably better not use that change at all.

trasher avatar Nov 21 '25 09:11 trasher

In another message sent, I saw that it was said the problem was apparently resolved, but after testing in a development environment, the same type of error persists.

The version I am currently using is: GLPI 12.0.0-dev - dev-e67b300.tar.gz

[2025-11-21 10:17:31] glpi.ERROR: *** Caught RuntimeException: MySQL query error: Duplicate entry 'Computer-21883-223988' for key 'glpi_items_softwareversions.unicity' (1062) in SQL query "UPDATE glpi_items_softwareversions SET softwareversions_id = '223988' WHERE id = '5681976'". Backtrace : ./src/DBmysql.php:371
./src/DBmysql.php:1446 DBmysql->doQuery() ./src/Transfer.php:1708 DBmysql->update() ./src/Transfer.php:1271 Transfer->transferItemSoftwares() ./src/Transfer.php:246 Transfer->transferItem() ./front/transfer.action.php:51 Transfer->moveItems() ...Glpi/Controller/LegacyFileLoadController.php:64 require() ./vendor/symfony/http-kernel/HttpKernel.php:181 Glpi\Controller\LegacyFileLoadController->__invoke() ./vendor/symfony/http-kernel/HttpKernel.php:76 Symfony\Component\HttpKernel\HttpKernel->handleRaw() ./vendor/symfony/http-kernel/Kernel.php:197 Symfony\Component\HttpKernel\HttpKernel->handle() ./public/index.php:70 Symfony\Component\HttpKernel\Kernel->handle()

FelipeBasilio1991 avatar Nov 21 '25 10:11 FelipeBasilio1991

In another message sent, I saw that it was said the problem was apparently resolved, but after testing in a development environment, the same type of error persists.

This issue is not solved.

trasher avatar Nov 21 '25 10:11 trasher

Hi, I confirm this too in GLPI 11.0.3 : When I transfer a ticket to another entity I get :

"POST /front/transfer.action.php HTTP/1.1" 200 39087 "https://glpi.domain/front/transfer.action.php" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36"

==> /var/log/glpi/php-errors.log <== [2025-11-25 15:48:17] glpi.ERROR: *** Caught RuntimeException: MySQL query error: Duplicate entry '23001-Ticket-66134--1' for key 'glpi_documents_items.unicity' (1062) in SQL query "UPDATE glpi_documents_items SET documents_id = '23001' WHERE id = '64748'". Backtrace : ./src/DBmysql.php:371 ./src/DBmysql.php:1446 DBmysql->doQuery() ./src/Transfer.php:2412 DBmysql->update() ./src/Transfer.php:1196 Transfer->transferDocuments() ./src/Transfer.php:246 Transfer->transferItem() ./front/transfer.action.php:51 Transfer->moveItems() ...Glpi/Controller/LegacyFileLoadController.php:64 require() ./vendor/symfony/http-kernel/HttpKernel.php:181 Glpi\Controller\LegacyFileLoadController->__invoke() ./vendor/symfony/http-kernel/HttpKernel.php:76 Symfony\Component\HttpKernel\HttpKernel->handleRaw() ./vendor/symfony/http-kernel/Kernel.php:197 Symfony\Component\HttpKernel\HttpKernel->handle() ./public/index.php:70 Symfony\Component\HttpKernel\Kernel->handle()

It worked fine in GLPI 10 (I don't remember the subversion, but it was the latest)

Hoping it helps, hhanks in advance

InformatiqueOLLN avatar Nov 25 '25 14:11 InformatiqueOLLN

We are having a similar issue when trying to transfer a ticket from entity A to entity B:

==> /var/log/glpi/php-errors.log <== [2025-11-28 14:01:36] glpi.ERROR: *** Caught RuntimeException: MySQL query error: Duplicate entry '270-Ticket-252--1' for key 'unicity' (1062) in SQL query "UPDATE glpi_documents_items SET documents_id = '270' WHERE id = '687'". Backtrace : ./src/DBmysql.php:371 ./src/DBmysql.php:1446 DBmysql->doQuery() ./src/Transfer.php:2412 DBmysql->update() ./src/Transfer.php:1196 Transfer->transferDocuments() ./src/Transfer.php:246 Transfer->transferItem() ./front/transfer.action.php:51 Transfer->moveItems() ...Glpi/Controller/LegacyFileLoadController.php:64 require() ./vendor/symfony/http-kernel/HttpKernel.php:181 Glpi\Controller\LegacyFileLoadController->__invoke() ./vendor/symfony/http-kernel/HttpKernel.php:76 Symfony\Component\HttpKernel\HttpKernel->handleRaw() ./vendor/symfony/http-kernel/Kernel.php:197 Symfony\Component\HttpKernel\HttpKernel->handle() ./public/index.php:70 Symfony\Component\HttpKernel\Kernel->handle()

^C

**edit: Removing documents from the requester's follow-up allows the transfer of the ticket to work properly.

dioig0 avatar Nov 28 '25 17:11 dioig0

The problem is still present in version 11.0.4. I hope it will be resolved in the next milestone. I don't know how to fix it.

teopost avatar Dec 05 '25 14:12 teopost

Update Now to 11.0.4 and confirm still

sagituga avatar Dec 08 '25 12:12 sagituga

Yes, this issue is not solved, and still opened. I will be closed once resolved.

trasher avatar Dec 08 '25 12:12 trasher