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

applied configureawait to eleminate the deadlock problem. #545

Merged
merged 1 commit into from Feb 27, 2014

Conversation

Projects
None yet
3 participants
@tugberkugurlu
Copy link
Contributor

commented Jan 13, 2014

I had to have the following query on the IAsyncDocumentSession as ASP.NET MVC child actions don't support async:

[ChildActionOnly]
public ActionResult List()
{
    IEnumerable<Tags_Count.ReduceResult> tags = _documentSession
        .Query<Tags_Count.ReduceResult, Tags_Count>()
        .ToListAsync()
        .Result;

    return View(tags.Select(tag => new TagModel
    {
        Name = tag.Name,
        Slug = tag.Slug,
        Count = tag.Count,
        LastSeenAt = tag.LastSeenAt
    }));
}

However, this call will causes deadlock because of the reasons explained in the following articles and questions:

Hope this helps.

Not completely sure if this pull-request completely fixes this problem (as nearly every await needs to be made against ConfigureAwait(false) in a library which doesn't care about the sync. context) but I just wanted to raise the problem here with this pull request.

@ghost

This comment has been minimized.

Copy link
Collaborator

commented Jan 13, 2014

Hi,
Do you have a CLA with us?

Oren Eini
CEO
Hibernating Rhinos
Cellular: +972-52-548-6969
Office: +972-4-674-7811
Fax: +972-153-4622-7811

On Mon, Jan 13, 2014 at 2:30 AM, Tugberk Ugurlu notifications@github.comwrote:

I had to have the following query on the IAsyncDocumentSession as ASP.NETMVC child actions don't support async:

[ChildActionOnly]
public ActionResult List()
{
IEnumerable<Tags_Count.ReduceResult> tags = _documentSession
.Query<Tags_Count.ReduceResult, Tags_Count>()
.ToListAsync()
.Result;

return View(tags.Select(tag => new TagModel
{
    Name = tag.Name,
    Slug = tag.Slug,
    Count = tag.Count,
    LastSeenAt = tag.LastSeenAt
}));

}

However, this call will cause a deadlock because of the reasons explained
in the following articles and questions:

  • The Perfect Recipe to Shoot Yourself in The Foot - Ending up with a
    Deadlock Using the C# 5.0 Asynchronous Language Featureshttp://www.tugberkugurlu.com/archive/the-perfect-recipe-to-shoot-yourself-in-the-foot-ending-up-with-a-deadlock-using-the-c-sharp-5-0-asynchronous-language-features
  • Asynchronous .NET Client Libraries for Your HTTP API and Awareness
    of async/await's Bad Effectshttp://www.tugberkugurlu.com/archive/asynchronousnet-client-libraries-for-your-http-api-and-awareness-of-async-await-s-bad-effects
  • Best practice to call ConfigureAwait for all server-side codehttp://stackoverflow.com/questions/13489065/best-practice-to-call-configureawait-for-all-server-side-code

Hope this helps.

Not completely sure if this pull-request completely fixes this problem (as
nearly every await needs to be made against ConfigureAwait(false) in a
library which doesn't care about the sync. context) but I just wanted to

raise the problem here with this pull request.

You can merge this Pull Request by running

git pull https://github.com/tugberkugurlu/ravendb configureawait

Or view, comment on, or merge it at:

#545
Commit Summary

  • applied configureawait to eleminate the deadlock problem.

File Changes

  • M Raven.Client.Lightweight/Changes/RemoteDatabaseChanges.cshttps://github.com//pull/545/files#diff-0(18)
  • M Raven.Client.Lightweight/Connection/Async/AsyncServerClient.cshttps://github.com//pull/545/files#diff-1(50)
  • M Raven.Client.Lightweight/Connection/HttpJsonRequest.cshttps://github.com//pull/545/files#diff-2(34)
  • M Raven.Client.Lightweight/Connection/ObservableLineStream.cshttps://github.com//pull/545/files#diff-3(2)
  • M Raven.Client.Lightweight/Connection/Operation.cshttps://github.com//pull/545/files#diff-4(6)
  • M Raven.Client.Lightweight/Document/Async/AsyncDocumentSession.cshttps://github.com//pull/545/files#diff-5(20)
  • M Raven.Client.Lightweight/Extensions/MultiTenancyExtensions.cshttps://github.com//pull/545/files#diff-6(6)
  • M Raven.Client.Lightweight/PublicExtensions/LinqExtensions.cshttps://github.com//pull/545/files#diff-7(24)
  • M Raven.Client.Lightweight/Shard/AsyncShardedDocumentSession.cshttps://github.com//pull/545/files#diff-8(14)
  • M Raven.Client.Lightweight/Shard/ShardedRavenQueryInspector.cshttps://github.com//pull/545/files#diff-9(4)
  • M RavenDB.sln.DotSettingshttps://github.com//pull/545/files#diff-10(3)

Patch Links:


Reply to this email directly or view it on GitHubhttps://github.com//pull/545
.

@tugberkugurlu

This comment has been minimized.

Copy link
Contributor Author

commented Jan 13, 2014

Hi,

I have just sent the CLA to support email available here: http://ravendb.net/contributing. You should have received it by now.

@fitzchak fitzchak merged commit bd7001c into ravendb:master Feb 27, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.