Problem/Motivation
When deploying a change for a new plugin on a website, it is possible for the discovery cache to be set during config import (in an environment where the changes are not yet released). Because of this, the import does not recognize the new plugin and throws an error.
Steps to Reproduce
This is kind of hard to reproduce.
Create a new plugin (rest resource, for example) and run config import.
During config import (after webroot/core/lib/Drupal/Core/Extension/ModuleInstaller.php:277), invoke the cache for the same site but without this new change in it.
This should now throw an error that your new plugin does not exist.
Proposed Resolution
Add a deploy identifier to the cache_key in \Drupal\Core\Plugin\DefaultPluginManager::setCacheBackend.
This will create a cache_discovery different for each deployment. (see patch)