Skip to content

Settings streams exchange semantics - #1534

Merged
JohnMcPMS merged 9 commits into
microsoft:masterfrom
JohnMcPMS:settingssync
Oct 4, 2021
Merged

JohnMcPMS merged 9 commits into
microsoft:masterfrom
JohnMcPMS:settingssync

Conversation

@JohnMcPMS

@JohnMcPMS JohnMcPMS commented Oct 1, 2021 •

Copy link
Copy Markdown
Member

Fixes #463

Change

The goal of this change is to add exchange semantics to settings stream writes. Currently they do not have any interprocess synchronization. This does not lead to corrupted streams as the underlying systems prevent simultaneous writes, but it can lead to data loss if updates from one process are not merged with those from another.

Because holding any kind of lock would likely lead to contention amongst the processes, we use exchange semantics instead. Writes are only permitted if the stream has not changed since it was last read. This required moving to a more object oriented model for the settings streams, which then required updating the consumers of it to also maintain an object and respond to failed write attempts.

The update to AdminSettings was fairly straightforward, requiring just the necessary interface updates and the exchange retry loop.

For SourceListInternal, I also refactored the code out of RepositorySource.cpp which was getting quite large. I moved the group policy related functions to their own file (SourcePolicy.cpp) and the source enumeration related functions to theirs (SourceList.cpp). The renamed SourceList type now maintains the stream objects for its lifetime and manages the necessary exchange retry attempts for the various writes that are required.

Validation

New unit tests are added to validate the code under controlled circumstances. Functional tests would be impractical to write as the actual interactions are races between various writes, although the configurable test source that was added recently would aid in this area.

Microsoft Reviewers: Open in CodeFlow

@JohnMcPMS
JohnMcPMS requested a review from a team as a code owner October 1, 2021 03:03
@ghost ghost added the Issue-Bug It either shouldn't be doing this or needs an investigation. label Oct 1, 2021
Comment thread src/AppInstallerCommonCore/Settings.cpp Resolved
Comment thread src/AppInstallerCommonCore/Settings.cpp Resolved

@yao-msft yao-msft left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@JohnMcPMS
JohnMcPMS merged commit fe8c617 into microsoft:master Oct 4, 2021
@JohnMcPMS
JohnMcPMS deleted the settingssync branch October 4, 2021 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Issue-Bug It either shouldn't be doing this or needs an investigation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Settings stream access is not synchronized cross process

2 participants