RavenDB 3.5 - Initialize() hanging

26 views
Skip to first unread message

Tobi

unread,
Feb 19, 2018, 6:05:38 AM2/19/18
to rav...@googlegroups.com
I haven't digged deeper into this yet, but maybe someone already
stumbled upon this.

Why is the following code hanging in Initialize()?

using System.Threading.Tasks;
using Nito.AsyncEx;
using Raven.Client.Embedded;

namespace AsyncRavenDbConsoleTest
{
class Program
{
static void Main(string[] args)
{
AsyncContext.Run(MainAsync);
}

private static async Task MainAsync()
{
using (var embeddableDocumentStore = new
EmbeddableDocumentStore
{
RunInMemory = true
})
{
embeddableDocumentStore.Initialize();
}
}
}
}


Tobias

Oren Eini (Ayende Rahien)

unread,
Feb 19, 2018, 7:36:23 AM2/19/18
to ravendb
We haven't seen that, I assume it it something related to the async context, but that is very strange.

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 




--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tobi

unread,
Feb 19, 2018, 11:17:18 AM2/19/18
to rav...@googlegroups.com
Yes it's probably the synchronisation context. I saw this happening in
parallel running unit tests, so I tried to reproduce this in a console
application.

Digging a little bit into this, the first thing that doesn't work, is
the background task created in class TransactionMergingWriter. Using
TaskScheduler.Default instead of TaskScheduler.Current there makes this
background task at least run.

The next issue is with the AsyncServerClient executing async operations
in its ctor using AsyncHelpers.RunSync(). I'm definitly not an
async/await guru - but this looks wrong.

Tobias


Am 19.02.2018 um 13:35 schrieb Oren Eini (Ayende Rahien):
> We haven't seen that, I assume it it something related to the async
> context, but that is very strange.
>
> */Hibernating Rhinos Ltd /*____
>
> Oren Eini* lCEO l *Mobile: + 972-52-548-6969
>
> Office: +972-4-622-7811 *l*Fax: +972-153-4-622-7811
>
> __
>
> __
>
>
> On Mon, Feb 19, 2018 at 1:05 PM, Tobi <lista...@e-tobi.net
> <mailto:lista...@e-tobi.net>> wrote:
>
> I haven't digged deeper into this yet, but maybe someone already
> stumbled upon this.
>
> Why is the following code hanging in Initialize()?
>
> using System.Threading.Tasks;
> using Nito.AsyncEx;
> using Raven.Client.Embedded;
>
> namespace AsyncRavenDbConsoleTest
> {
>     class Program
>     {
>         static void Main(string[] args)
>         {
>             AsyncContext.Run(MainAsync);
>         }
>
>         private static async Task MainAsync()
>         {
>             using (var embeddableDocumentStore = new
> EmbeddableDocumentStore
>             {
>                 RunInMemory = true
>             })
>             {
>                 embeddableDocumentStore.Initialize();
>             }
>         }
>     }
> }
>
>
> Tobias
>
> --
> You received this message because you are subscribed to the Google
> Groups "RavenDB - 2nd generation document database" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to ravendb+u...@googlegroups.com
> <mailto:ravendb%2Bunsu...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "RavenDB - 2nd generation document database" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ravendb+u...@googlegroups.com
> <mailto:ravendb+u...@googlegroups.com>.

Tobi

unread,
Feb 19, 2018, 11:22:09 AM2/19/18
to rav...@googlegroups.com
PS: Dirty work-around:


private static async Task MainAsync()
{
using (var embeddableDocumentStore = new EmbeddableDocumentStore
{
RunInMemory = true
})
{
await Task.Factory.StartNew(() =>
{
embeddableDocumentStore.Initialize();
}, CancellationToken.None, TaskCreationOptions.None,
TaskScheduler.Default).ConfigureAwait(false);

Oren Eini (Ayende Rahien)

unread,
Feb 19, 2018, 3:23:59 PM2/19/18
to ravendb
Yes, I'm pretty sure that we this code just assumed that this is all just running on the default task scheduler.

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 



    For more options, visit https://groups.google.com/d/optout
    <https://groups.google.com/d/optout>.


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com <mailto:ravendb+unsubscribe@googlegroups.com>.

For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

Tobi

unread,
Feb 19, 2018, 5:01:29 PM2/19/18
to rav...@googlegroups.com
Which might not be a wise assumption.

Just saw that I already stumbled upon this 4 years ago at a different place:

http://issues.hibernatingrhinos.com/issue/RavenDB-1691

...fixed in e351ba1e76

And I guess there should be an InitializeAsync() code path to avoid having
those ugly AsyncHelpers.RunSync() calls.

Any chance a PR for 3.5.x would be accepted?

I'm afraid 4.0 is not yet an option for me to replace the embedded 3.5.5
I'm using right now.

Tobia

On 19.02.2018 21:23, Oren Eini (Ayende Rahien) wrote:

> Yes, I'm pretty sure that we this code just assumed that this is all just
> running on the default task scheduler.
>
> */Hibernating Rhinos Ltd  /*____
>
> Oren Eini* l CEO l *Mobile: + 972-52-548-6969
>
> Office: +972-4-622-7811 *l *Fax: +972-153-4-622-7811
>
> __
>
> __ 
> <tel:%2B%20972-52-548-6969>
>
> Office: +972-4-622-7811 <tel:%2B972-4-622-7811> *l*Fax:
> +972-153-4-622-7811 <tel:%2B972-153-4-622-7811>
>
> __
>
> __
>
>
> On Mon, Feb 19, 2018 at 1:05 PM, Tobi <lista...@e-tobi.net
> <mailto:lista...@e-tobi.net> <mailto:lista...@e-tobi.net
> <mailto:lista...@e-tobi.net>>> wrote:
>
>     I haven't digged deeper into this yet, but maybe someone
> already
>     stumbled upon this.
>
>     Why is the following code hanging in Initialize()?
>
>     using System.Threading.Tasks;
>     using Nito.AsyncEx;
>     using Raven.Client.Embedded;
>
>     namespace AsyncRavenDbConsoleTest
>     {
>          class Program
>          {
>              static void Main(string[] args)
>              {
>                  AsyncContext.Run(MainAsync);
>              }
>
>              private static async Task MainAsync()
>              {
>                  using (var embeddableDocumentStore = new
>     EmbeddableDocumentStore
>                  {
>                      RunInMemory = true
>                  })
>                  {
>                      embeddableDocumentStore.Initialize();
>                  }
>              }
>          }
>     }
>
>
>     Tobias
>
>     --     You received this message because you are
> subscribed to the Google
>     Groups "RavenDB - 2nd generation document database" group.
>     To unsubscribe from this group and stop receiving emails
> from it,
>     send an email to ravendb+u...@googlegroups.com
> <mailto:ravendb%2Bunsu...@googlegroups.com>
>     <mailto:ravendb%2Bunsu...@googlegroups.com
> <mailto:ravendb%252Buns...@googlegroups.com>>.
>     For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>
>     <https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>>.
>
>
> --
> You received this message because you are subscribed to the
> Google Groups "RavenDB - 2nd generation document database" group.
> To unsubscribe from this group and stop receiving emails from
> it, send an email to ravendb+u...@googlegroups.com
> <mailto:ravendb%2Bunsu...@googlegroups.com>
> <mailto:ravendb+u...@googlegroups.com
> <mailto:ravendb%2Bunsu...@googlegroups.com>>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "RavenDB - 2nd generation document database" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ravendb+u...@googlegroups.com
> <mailto:ravendb%2Bunsu...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "RavenDB - 2nd generation document database" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ravendb+u...@googlegroups.com
> <mailto:ravendb+u...@googlegroups.com>.

Oren Eini (Ayende Rahien)

unread,
Feb 19, 2018, 10:08:58 PM2/19/18
to ravendb
A PR would be welcome, yes

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


>                 send an email to ravendb+unsubscribe@googlegroups.com
>             <mailto:ravendb%2Bunsubscribe@googlegroups.com>
>                 <mailto:ravendb%2Bunsubscribe@googlegroups.com
>             <mailto:ravendb%252Bunsubscribe@googlegroups.com>>.
>                 For more options, visit https://groups.google.com/d/optout
>             <https://groups.google.com/d/optout>
>                 <https://groups.google.com/d/optout
>             <https://groups.google.com/d/optout>>.
>
>
>             --
>             You received this message because you are subscribed to the
>             Google Groups "RavenDB - 2nd generation document database" group.
>             To unsubscribe from this group and stop receiving emails from
>             it, send an email to ravendb+unsubscribe@googlegroups.com
>             <mailto:ravendb%2Bunsubscribe@googlegroups.com>
>             <mailto:ravendb+unsubscribe@googlegroups.com
>             <mailto:ravendb%2Bunsubscribe@googlegroups.com>>.

>             For more options, visit https://groups.google.com/d/optout
>             <https://groups.google.com/d/optout>.
>
>
>
>     --
>     You received this message because you are subscribed to the Google
>     Groups "RavenDB - 2nd generation document database" group.
>     To unsubscribe from this group and stop receiving emails from it, send

>     For more options, visit https://groups.google.com/d/optout
>     <https://groups.google.com/d/optout>.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "RavenDB - 2nd generation document database" group.
> To unsubscribe from this group and stop receiving emails from it, send an

> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages