glpi-project / glpi-inventory-plugin

GLPI Inventory plugin
GNU Affero General Public License v3.0
46 stars 27 forks source link

slow loading of the package deploy tab #381

Closed kintaro1981 closed 8 months ago

kintaro1981 commented 1 year ago

Describe the bug

Clicking in the package deploy tab takes several seconds to loade the page. All the other pages and tabs load istantly.

Loading http://glpi/plugins/glpiinventory/front/deploypackage.php don't produce this issue, the problem is only clicking on the package deploy tab.

To reproduce

  1. Search for a computer
  2. Open the computer page
  3. Click on the tabs Package Deploy

Expected behavior

The page loads like the other ones.

Operating system

Other (See additional context below)

GLPI Agent version

Other (See additional context below)

GLPI version

10.0.9

GLPIInventory plugin

1.2.3

Additional context

operating system and agent version are not involved in this issue

kintaro1981 commented 1 year ago

Do you think this a resource problem? All the other GLPI pages are very fast. Maybe is a too much aggressive query?

we have about: 109 packages 12 static groups 15 dynamic groups

stonebuzz commented 1 year ago

Hello,

your infrastructure could also be the cause, for example :

we've never had the opportunity to test the plugin on such a large volume.

If you use the plugin more than professionally, you should consider taking out a subscription to get professional support.

Best regards

kintaro1981 commented 1 year ago

We are not this big. We have 700 active agents (still on fusion-agent) but I created many packages because we don't have Active Directory and I use GLPI a lot to deploy software and os configurations.

I'm going to ask sysadmin to check the db when glpi hangs to understand if it's a lack of resources' issue.

kintaro1981 commented 1 year ago

Virtual machine GLPI DB in the the same machine. Mono processor RAM 6GB Only 2/3 people connect to GLPI gui as we don't publicied selfservice to users yet. We utilize it only internally as an inventory and package deploy.

All the other pages loads instantaneously.

With Analize in Firefox I can see this:

immagine

Anyone can reproduce it?

stonebuzz commented 1 year ago

How many package are available per Computer ?

kintaro1981 commented 1 year ago

for pc with about 90 packages (os 64bit) it takes from 20 to 25 seconds for pc with about 50 packages (os 32bit) is takes the same time, 20 to 25 seconds

it seams there's no correlation beetween the number of packages available and the load time :-(

How about cache the list and reload it only if there's a change in one or more package? I mean a change in the the entity target and/or to the group able to do deploy on demand of a package?

Here: immagine

and here: immagine

kintaro1981 commented 1 year ago

p.s. Tasks/Groups tabs loads instantly

stonebuzz commented 1 year ago

Can you create a deployment task for a single computer and see if it loads faster?

kintaro1981 commented 1 year ago

I found a pc that doesn't belong to any dynamic group and it take the same amount of time about 20/25 seconds to fully load Deploy Package tab and then it display: No packages available to install

immagine

kintaro1981 commented 1 year ago

Can you create a deployment task for a single computer and see if it loads faster?

wait I'm not talking about tasks but packages deploy

stonebuzz commented 1 year ago

With or without deploy task, tab is load like a charm

image

It may be linked to something else, but it's going to be complicated to find without having a hand

Perhaps you could enable the slow-query log in mysql to see if that's where the problem lies

Or perhaps consider taking out a subscription as you seem to have a very professional and sophisticated use of the plugin

This would enable us to resolve your problem more quickly and easily.

kintaro1981 commented 1 year ago

we are in the same page? your last row after id= there's tab_key=PluginGlpiinventory in my case is tab=30

in my case is common.tabs.php?_target=/front/computer.form.php&_itemtype=Computer&_glpi_tab=PluginGlpiinventoryDeployPackage$1&id=13718&withtemplate=&formoptions=data-track-changes%3Dtrue loads slow.

updatecurrenttab.php?itemtype=Computer&id=12830&tab=30&withtemplate=0 loads in a decent time to me too

stonebuzz commented 1 year ago

bad past, but same behavior load instantly image

kintaro1981 commented 1 year ago

I activated debug and got this screens. Can they help in some way? immagine immagine

stonebuzz commented 1 year ago

Database queries seems huge (1659 against 230 for me) !

can you disable all the other plugins (except glpiinventory) to see if it one of them might be at fault)

Can you retry with GLPI latest version (some optimization are added)

kintaro1981 commented 1 year ago

With only glpiinventory activated:

immagine

immagine

immagine

immagine

immagine

stonebuzz commented 1 year ago

I confess I don't understand and I'm afraid I can't help you any more than that I can't reproduce it myself

kintaro1981 commented 1 year ago

can you list the queries you have so I can take a look to the differences with ours? the strange thing is that "ours" 1500 queries take about 3 seconds, so it doesn't seam them the problem. Or maybe is something bound to them.

kintaro1981 commented 1 year ago

@stonebuzz ping 😄 as soon you have 2 minutes can you list "your" queries?

stonebuzz commented 1 year ago

hI @kintaro1981

Here are the only two requests concerning package deployment (when opening the Package Deploy tab in a Computer)

SELECT `job`.* 
FROM `glpi_plugin_glpiinventory_taskjobs` AS `job` LEFT JOIN `glpi_plugin_glpiinventory_tasks` AS `task` ON (`job`.`plugin_glpiinventory_tasks_id` = `task`.`id`) 
WHERE `task`.`is_deploy_on_demand` = '1' AND `task`.`is_active` = '1' AND `task`.`entities_id` IN ('0', '1')
SELECT DISTINCT `glpi_plugin_glpiinventory_deploypackages`.* 
FROM `glpi_plugin_glpiinventory_deploypackages` LEFT JOIN `glpi_plugin_glpiinventory_deploypackages_groups` ON (`glpi_plugin_glpiinventory_deploypackages`.`id` = `glpi_plugin_glpiinventory_deploypackages_groups`.`plugin_glpiinventory_deploypackages_id`) LEFT JOIN `glpi_plugin_glpiinventory_deploypackages_entities` ON (`glpi_plugin_glpiinventory_deploypackages`.`id` = `glpi_plugin_glpiinventory_deploypackages_entities`.`plugin_glpiinventory_deploypackages_id`) LEFT JOIN `glpi_plugin_glpiinventory_deploypackages_users` ON (`glpi_plugin_glpiinventory_deploypackages`.`id` = `glpi_plugin_glpiinventory_deploypackages_users`.`plugin_glpiinventory_deploypackages_id`) LEFT JOIN `glpi_plugin_glpiinventory_deploypackages_profiles` ON (`glpi_plugin_glpiinventory_deploypackages`.`id` = `glpi_plugin_glpiinventory_deploypackages_profiles`.`plugin_glpiinventory_deploypackages_id`) 
WHERE `glpi_plugin_glpiinventory_deploypackages`.`plugin_glpiinventory_deploygroups_id` > '0' AND (((`glpi_plugin_glpiinventory_deploypackages_entities`.`entities_id` = '0')) OR (`glpi_plugin_glpiinventory_deploypackages_users`.`users_id` = '2') OR (`glpi_plugin_glpiinventory_deploypackages_profiles`.`profiles_id` = '4'))
kintaro1981 commented 1 year ago

I delete some dynamic groups and now the page loads a little bit faster (10 seconds instead of 25), but the query number is still high (about 1100).

I noticed with debug enabled that deploy tab run many query but the strange thing is that it run multiple time the same queries, is it normal? see attached ods file.

Maybe the problem is in this redundant number of querys? The queries are done relatively fast (2 seconds) but maybe php scripts have to elaborate and/or wait data from them?

query_list_deploy_package_tab.ods

kintaro1981 commented 1 year ago

@stonebuzz about the query number: can you try to click con the package deploy tab and then reload the page? I'm getting low query number if I load the computer page and then click on package deploy (debug information at the bottom don't get updated with ajax) but a very high query number if I reload it because it display the query number of that specific tab.

Another thing: After this fix: https://github.com/glpi-project/glpi-inventory-plugin/pull/439 We are getting about 70 php notices (with debug active, see below). It is about the total number of existing tasks including, active, not active and deploy on demand too in http://glpi/marketplace/glpiinventory/front/task.php

PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
PHP Notice (8): Undefined index: type in /var/www/htdocs/glpi-10.0.10/marketplace/glpiinventory/inc/deploygroup.class.php at line 473
stonebuzz commented 1 year ago

Hi @kintaro1981

as requested there is a list of SQL query

SELECT `job`.*
FROM `glpi_plugin_glpiinventory_taskjobs` AS `job` LEFT JOIN `glpi_plugin_glpiinventory_tasks` AS `task` ON (`job`.`plugin_glpiinventory_tasks_id` = `task`.`id`) 
WHERE `task`.`is_deploy_on_demand` = '1' AND `task`.`is_active` = '1' AND `task`.`entities_id` IN ('0', '1', '2', '3')
0 ms    1

SELECT DISTINCT `glpi_plugin_glpiinventory_deploypackages`.*
FROM `glpi_plugin_glpiinventory_deploypackages` LEFT JOIN `glpi_plugin_glpiinventory_deploypackages_groups` ON (`glpi_plugin_glpiinventory_deploypackages`.`id` = `glpi_plugin_glpiinventory_deploypackages_groups`.`plugin_glpiinventory_deploypackages_id`) LEFT JOIN `glpi_plugin_glpiinventory_deploypackages_entities` ON (`glpi_plugin_glpiinventory_deploypackages`.`id` = `glpi_plugin_glpiinventory_deploypackages_entities`.`plugin_glpiinventory_deploypackages_id`) LEFT JOIN `glpi_plugin_glpiinventory_deploypackages_users` ON (`glpi_plugin_glpiinventory_deploypackages`.`id` = `glpi_plugin_glpiinventory_deploypackages_users`.`plugin_glpiinventory_deploypackages_id`) LEFT JOIN `glpi_plugin_glpiinventory_deploypackages_profiles` ON (`glpi_plugin_glpiinventory_deploypackages`.`id` = `glpi_plugin_glpiinventory_deploypackages_profiles`.`plugin_glpiinventory_deploypackages_id`) 
WHERE `glpi_plugin_glpiinventory_deploypackages`.`plugin_glpiinventory_deploygroups_id` > '0' AND (((`glpi_plugin_glpiinventory_deploypackages_entities`.`entities_id` = '0')) OR (`glpi_plugin_glpiinventory_deploypackages_users`.`users_id` = '2') OR (`glpi_plugin_glpiinventory_deploypackages_profiles`.`profiles_id` = '4'))
1 ms    1

SELECT *
FROM `glpi_plugin_glpiinventory_deploygroups`
WHERE `glpi_plugin_glpiinventory_deploygroups`.`id` = '4' LIMIT 1
0 ms    1

SELECT *
FROM `glpi_plugin_glpiinventory_deploygroups_staticdatas`
WHERE `plugin_glpiinventory_deploygroups_id` = '4' AND `itemtype` = 'Computer'
0 ms    1

For PHP Notice (8): Undefined index: type

can you try this -> https://github.com/glpi-project/glpi-inventory-plugin/pull/441

stonebuzz commented 11 months ago

hi @kintaro1981

for "slow loading"

I'm not sure how to help you, since I don't reproduce on my side.

Perhaps you should consider taking out a subscription to benefit from professional support. This would allow me (among other things) to take control of your instance for debugging purposes.

Best regards

kintaro1981 commented 9 months ago

We tried to update to 10.0.12. The problem is still there. I'm going to ask to my manager if we can consider a subscription.

trasher commented 8 months ago

Since we cannot reproduce; and existing data is certainly faulty; I close.

Feel free to reopen if you can provide a use case reproducing issue on a fresh install.