I have created a class that parses an xml file and then adds the appropriate modifications to the web.config in my SharePoint 2010 web applications. When a feature is activated the proper mods are added to the web.config and when it is deactivated or uninstalled the mods are retracted.
In my xml I have about 9 nodes that are marked EnsureSection so I can be sure that some of the elements I need for example and are in the web.config. I do not retract these nodes when a feature is deactivated since I don't want to interfere with someone else using those nodes in the application.
Today I was poking around with PowerShell and I noticed that when I get the web application contentservice and look at the WebConfigModifications collection in memory; the mods that are for ensuring sections have been replicated in the collection. They have been replicated the number of times that I have activated the feature from the Central Admin.
I have code that wraps the adding of the mods so if they are already present in the collection I do not re-add them. I do not understand why the items that I have marked as EnsureSection are being replicated in the collection. Does anyone know why those mods would be getting multiplied like that?