Skip to content

Chain capabilities snapshot to nominate restore and dependency tree dataflows#3167

Merged
natidea merged 2 commits intodev15.6-preview3from
natidea-deptreerace
Jan 23, 2018
Merged

Chain capabilities snapshot to nominate restore and dependency tree dataflows#3167
natidea merged 2 commits intodev15.6-preview3from
natidea-deptreerace

Conversation

@natidea
Copy link
Copy Markdown
Contributor

@natidea natidea commented Jan 19, 2018

A race condition in CPS is resulting from data flow action blocks being executed in the wrong capabilities context. This race condition may have been around for a while but is occurring much more frequently. CPS expects us to explicitly chain dataflows to the right capability context, so we are doing so in a number of cases where the symptoms of this race condition have become more pronounced. This PR fixes two cases:

  1. After opening .NET Core projects, NuGet restore fails to run, and all dependencies are unresolved. In this case, running in the wrong capabilities context causes a NuGet check for compatibility to fail so that it does not recognize .NET Core projects.
  2. Opening .NET Core projects sometimes produces spurious warnings in the dependencies tree, or an empty dependencies tree node, and these warnings do not go away following a build. In this case, running in the wrong capabilities context causes OrderPrecedenceImportCollection (used to import rule handlers and tree view providers) to return an empty collection from OrderPrecedenceImportCollection.GetFilteredSnapshot(), breaking the dependencies tree.

Customer scenario

Customers opening .NET Core projects sometimes see spurious warnings in the dependencies tree, or an empty dependencies tree node, and sometimes restore fails to run.

Bugs this fixes:

Fixes #3111
Fixes 553715

Workarounds, if any

Building the solution generally resolves case 1
Close and reopen solution sometimes resolves case 2

Risk

Should be low as the rest of the dataflow is unchanged

Performance impact

Low. Only change is to creating Isolated capabilities context, which is fast and necessary in any case

Is this a regression from a previous update?

Appears to have gotten worse in the latest bits, but its not clear why

Root cause analysis:

Pending: We are still trying to figure out the change that makes the race condition more frequent.

How was the bug found?

Numerous internal reports

Notes
I'm creating a signed build and VAL build to test this further.

This is to ensure accesses to OrderPrecedenceImportCollection (i.e. used to import rule handlers and tree view providers) occur in the right capabilities context. Occurrences in the wrong context led to a race condition in OrderPrecedenceImportCollection.GetFilteredSnapshot() which resulted in these collections being empty, breaking the dependencies tree.
@natidea natidea changed the title [WIP] Chain capabilities snapshot to dependency tree dataflow Chain capabilities snapshot to nominate restore and dependency tree dataflows Jan 23, 2018
@natidea
Copy link
Copy Markdown
Contributor Author

natidea commented Jan 23, 2018

/cc @lifengl

@natidea
Copy link
Copy Markdown
Contributor Author

natidea commented Jan 23, 2018

/cc @dotnet/project-system


await HandleAsync(e, handlerType).ConfigureAwait(false);

using (ProjectCapabilitiesContext.CreateIsolatedContext(configuredProject, e.Value.Item3))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it safe to await inside this using?

@Pilchie
Copy link
Copy Markdown
Member

Pilchie commented Jan 23, 2018

I'm okay with moving forward with this fix, but I'd really like to know what has caused all of these races to start appearing now? AFAIK, much of this hookup hasn't changed in a very long time.

Copy link
Copy Markdown
Contributor

@lifengl lifengl left a comment

Choose a reason for hiding this comment

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

the change looks good to me

@natidea
Copy link
Copy Markdown
Contributor Author

natidea commented Jan 23, 2018

Merging optimistically to catch insertion train.

@davkean
Copy link
Copy Markdown
Member

davkean commented Feb 14, 2018

@lifengl @jviau Would this likely have been caused by the changes to the factory, ie by making this more prevalent?

@davkean
Copy link
Copy Markdown
Member

davkean commented Feb 14, 2018

Also, what's the rules around when should we use a isolated capability snapshot?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants