Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A plugin might be installed several times concurrently #9211

Open
tsteur opened this issue Nov 12, 2015 · 5 comments
Open

A plugin might be installed several times concurrently #9211

tsteur opened this issue Nov 12, 2015 · 5 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc.

Comments

@tsteur
Copy link
Member

tsteur commented Nov 12, 2015

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: #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 tsteur added the Bug For errors / faults / flaws / inconsistencies etc. label Nov 12, 2015
@tsteur
Copy link
Member Author

tsteur commented Nov 12, 2015

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
Copy link
Member Author

tsteur commented Nov 12, 2015

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
Copy link
Member Author

tsteur commented Nov 12, 2015

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
Copy link

hpvd commented Nov 13, 2015

Is this in any way related to #6737?
or is #6737 only a "cosmetic" problem?

@tsteur
Copy link
Member Author

tsteur commented Nov 15, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

3 participants