Added support for disabling loading all site collection term groups #1069
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull requests adds the support to disable the loading of all site collection-related term groups when initializing the
TokenParser
.Currently
TokenParser.AddTermStoreTokens
would load all available term groups from the term store when at least onetermsetid
token was found. Yesterday (2024-10-07) at 9:21 UTC we encountered the first instance of a timeout issue on one larger tenant, which was clearly caused by theAddTermStoreTokens
method ofTokenParser
due to the stack trace. The request was canceled after three minutes.After some manual tests we figured out that loading all available term groups with their term sets caused the issue. Removing the term sets from the loading process solved the problem, but would defeat the purpose of the whole operation. During those tests we also realized that loading the term groups without any conditions would return (on that tenant) over 29,000 entries. Most of them were site collection term groups. The same operation on another large tenant finished after a few seconds, but returned only around 28,800 entries. So we don't know if this is just an issue on that one specific tenant, or if 29,000 is somehow a magic barrier and the other tenant is just on the edge to experience the same issue.
This could also be caused by one or more site collection term groups, which contain a larger amount of term sets, but we have not checked this yet. It also does not make in most cases sense for PnP to load all term groups including the site collection ones, because most templates might contain a reference to the site collection term group of the site it gets applied to, but not references to those from other site collections. Excluding them also greatly reduces the amount of tokens the
TokenParser
has to handle.To remedy this issue we added the
LoadSiteCollectionTermGroups
property to theProvisioningTemplateApplyingInformation
andProvisioningTemplateCreationInformation
class. It istrue
by default to ensure the same behavior as before. Changing it tofalse
will change the query with which the term groups get loaded from a normalLoad
to aLoadQuery
, that excludes all groups which are related to a site collection (IsSiteCollectionGroup
property). Thesitecollectionterm
token are not affected by this change andAddTermStoreTokens
will still load information about the term group of the current site collection. Beside theTokenParser
classObjectTermGroups
andObjectHierarchySequenceTermGroups
have been changed too, because they also load all term groups and would cause the same issue.We tested the changes and deployed them already to our production environment using a reference to the project instead of using the NuGet package, because it was no longer possible to deploy any templates due to the timeout issue. We haven't seen any issues related to the changes yet. The hierarchy-related logic has also been changed, but because we don't use it it was not easily possible to test.