@tsteur opened this Issue on November 12th 2015 Member

I just had a look at the plugin install code in PluginManager: https://github.com/piwik/piwik/blob/2.15.1-b1/core/Plugin/Manager.php#L1068-L1071

What happens is that we detect a loaded plugin and check if it's installed or not. If it is not installed yet, we install it and add it to the list of installed plugins afterwards.

The problem is that there might be several other requests during a plugin installation and they will all try to install the plugin concurrently as we only add the PluginInstalled flag after installation (which is correct). This can lead to errors like this where a plugin is not installed correctly: https://github.com/piwik/piwik/issues/8683

We need something like a new flat PluginInstallationInProgress[]=PluginName and if there is already one installation in progress we should not start the installation process again.

The longer a plugin installation takes, the higher the chance that the installation will end up with errors. In case of the new plugin CustomDimensions #9129 whose installation may take several hours we would not only add 5 custom dimensions but Number of Request to Piwik during that time frame * 5 custom dimensions. I have not tested it but I'm sure this is what would possibly happen.

@tsteur commented on November 12th 2015 Member

Also whenever we install a plugin we should check whether config is actually writable before we start installing. Just mentioning in case we don't do it yet.

@tsteur commented on November 12th 2015 Member

I quickly tried to implement it via config.ini.php but it's not trivial. Eg if the script that installs the plugin times out the plugin would be still marked as currently installing and no new attempt in installing the plugin again would be made.

We'd kinda have to use something like Piwik\CliMulti\Process and use PID of the process that is installing the plugin to see if the process is still running but this doesn't work across all systems (eg we have some problems on some *nix systems and windows).

@tsteur commented on November 12th 2015 Member

From the looks this might be actually only a problem if the plugin exists in Plugins[] config but not in PluginsInstalled[] which is the case for most Core plugins and explains why it might happened for Custom Variables plugin in #8683.

Normal workflow via UI or console command for 3rd party plugins, when activating a plugin, is to install it first and then add it to Plugins[]. Meaning it should be only loaded when it is actually installed.

@hpvd commented on November 13th 2015

Is this in any way related to https://github.com/piwik/piwik/issues/6737?
or is #6737 only a "cosmetic" problem?

@tsteur commented on November 15th 2015 Member

It is not related to #6737 and not only a cosmetic problem. I think #6737 would be actually easy to fix but the problem is it will take a while to be able to reproduce it

Powered by GitHub Issue Mirror