Add mutex lock to saveSettings storage call #2737
Merged
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.
Fixes #2736
When disabling (or enabling) a module that contains lots of individual node sets (ie .js files), the code disables each one in turn - but without any locking to ensure one is done before the next is disabled. Each call to disable causes the settings file to be updated to record the set as being disabled.
This would cause multiple calls to
saveSettings
that overlap, leading to the error reported in #2736This fix is to add a mutex lock on
saveSettings
to ensure it can only have one active call at a time. Applying the fix here will ensure the same symptom can't crop up through other parts of the API that drive rapid changes to the settings file.There is a separate item to consider - that disabling a whole module causes so many calls to update settings. It would be nice if the calls could be batched up as we know we're about to make lots of updates. The tricky part is how far apart the logic to disable an individual set and the logic to disable the whole module sits. That's for another day.