Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle failed SaveAsync operations #51244

Merged
merged 2 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices)

// MemoryMapped files which are used by the TemporaryStorageService are present in .NET Framework (including Mono)
// and .NET Core Windows. For non-Windows .NET Core scenarios, we can return the TrivialTemporaryStorageService
// until https://github.com/dotnet/roslyn/issues/42178 is fixed.
// until https://github.com/dotnet/runtime/issues/30878 is fixed.
return PlatformInformation.IsWindows || PlatformInformation.IsRunningOnMono
? (ITemporaryStorageService)new TemporaryStorageService(textFactory)
: TrivialTemporaryStorageService.Instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ private void ResetRecoverySource(Task saveTask, T instance)
{
using (Gate.DisposableWait(CancellationToken.None))
{
_recoverySource = new AsyncLazy<T>(RecoverAsync, Recover, cacheResult: false);
// Only assume the instance is saved if the saveTask completed successfully. If the save did not
// complete, we can still rely on a constant value source to provide the instance.
_recoverySource = saveTask.Status == TaskStatus.RanToCompletion
? new AsyncLazy<T>(RecoverAsync, Recover, cacheResult: false)
: new ConstantValueSource<T>(instance);
Copy link
Member

Choose a reason for hiding this comment

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

this makes sense. though i worry about waht is breaking teh saveTask. do we have insight on that? Can we report/log failures of that as well so we can track down any other necessary fixes?

Copy link
Member Author

@sharwell sharwell Feb 19, 2021

Choose a reason for hiding this comment

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

We already do log NFE for failure of saveTask. @ryzngard could look up telemetry for it.

(EnsureInstanceIsSavedAsync uses SafeContinueWithFromAsync)


// Need to keep instance alive until recovery source is updated.
GC.KeepAlive(instance);
Expand Down