Null reference exception while trying to enumerate an empty list (Raven4)

45 views
Skip to first unread message

Marcelo Volmaro

unread,
Jun 16, 2017, 12:09:11 PM6/16/17
to RavenDB - 2nd generation document database
I have the following code

var query = _session.Query<BinaryFile>();
using (var enumerator = await _session.Advanced.StreamAsync(query))
{
var hashset = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
while (await enumerator.MoveNextAsync())
{
}
return hashset;
}

The collection I'm querying is empty (there are no BinaryFile(s) in the DB). Raven is throwing the following exception:

   at Raven.Client.Documents.Session.Operations.StreamOperation.YieldStreamResults.<InitializeAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Raven.Client.Documents.Session.Operations.StreamOperation.YieldStreamResults.<MoveNextAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Raven.Client.Documents.Session.AsyncDocumentSession.YieldStream`1.<MoveNextAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at DDS.Synchronizer.Server.Repository.Repositories.BinariesRepository.<LoadAllAsync>d__8.MoveNext() in D:\Code\2DS\Aplicaciones\Synchronizer\DDS.Synchronizer.Server\Repository\Repositories\BinariesRepository.cs:line 89

I would expect this not to fail and just return (in my case) an empty hashset...

Marcelo Volmaro

unread,
Jun 16, 2017, 3:45:06 PM6/16/17
to RavenDB - 2nd generation document database
Just to expand.. it is throwing the NRE even with items in the collection...

Oren Eini (Ayende Rahien)

unread,
Jun 17, 2017, 5:15:11 AM6/17/17
to ravendb
This shouldn't do that, obviously. Can you send a failing test?
It is working on my end, so something strange is going on.

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.

Marcelo Volmaro

unread,
Jun 17, 2017, 8:30:41 AM6/17/17
to RavenDB - 2nd generation document database
Will try, but this is part of a bigger app and I'm not sure I will be able to create a test. Just one note: Every "BinaryFile" has an attachment attached... Maybe that's something related?

Definition of BinaryFile:
public sealed class BinaryFile : IStorable
{
public BinaryFile()
{
Created = DateTime.UtcNow;
}
[Sparrow.Json.JsonIgnore]
[Newtonsoft.Json.JsonIgnore]
public Stream Stream { get; set; }
public string Id { get; set; }
public DateTime Created { get; set; }
public DateTime Modified { get; set; }
}

Index:
internal sealed class BinaryFile_Indexes : AbstractIndexCreationTask<BinaryFile> { }
(I force the existence of an index, even if it's empty)

One document example:
{
    "Created": "2017-06-16T19:31:30.6061761Z",
    "Modified": "2017-06-16T19:31:30.6061761Z",
    "@metadata": {
        "@collection": "BinaryFiles",
        "Raven-Clr-Type": "DDS.Synchronizer.Server.Data.BinaryFile, DDS.Synchronizer.Server",
        "@flags": "HasAttachments",
        "@change-vector": [
            {
                "Etag": 39,
                "DbId": "26e3e358-939b-4d75-9982-86cacfc94cdb"
            }
        ]
    }
}
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.

Oren Eini (Ayende Rahien)

unread,
Jun 17, 2017, 8:35:12 AM6/17/17
to ravendb
internal sealed class BinaryFile_Indexes : AbstractIndexCreationTask<BinaryFile> { }

Huh, this should actually be an error, there is no index that is created from here. 
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

Marcelo Volmaro

unread,
Jun 17, 2017, 9:12:53 AM6/17/17
to RavenDB - 2nd generation document database
Ok, so, two things:
1) A better error message, like "You #@! moron!, You need to have something in your indexes" (or something like that) :)
2) Why it matters? I'm not querying against the index anyways...

Oren Eini (Ayende Rahien)

unread,
Jun 17, 2017, 9:15:42 AM6/17/17
to ravendb
1) It should do that, actually. 
2) I'm not sure, it shouldn't. That is why I asked if you can sedn a repro
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

Marcelo Volmaro

unread,
Jun 17, 2017, 9:23:47 AM6/17/17
to RavenDB - 2nd generation document database
1) Well, it is not working. At least not with the above repro, as that's exactly the code I have and I never saw that error.
2) Probably because (1). I will try to create a repro on Monday...

Marcelo Volmaro

unread,
Jun 17, 2017, 11:09:39 AM6/17/17
to RavenDB - 2nd generation document database
Ok. This is happening because I'm not registering the index in the DB. That's why I never saw your error.
There you have a way to reproduce it...
So, basically, I created an empty index, I did not register it (with Index.Execute(store)), and then I tried the query above (that doesn't hits any indexes).

Oren Eini (Ayende Rahien)

unread,
Jun 17, 2017, 11:11:52 AM6/17/17
to ravendb
If the index hasn't been registered in the server, there is no way that this is related. We do no scanning for indexes as part the query.
Do you have a standalone repro of this?
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

Marcelo Volmaro

unread,
Jun 17, 2017, 11:34:51 AM6/17/17
to RavenDB - 2nd generation document database
No, but will try, as I removed the index and I'm still getting the NRE...

Marcelo Volmaro

unread,
Jun 17, 2017, 5:55:31 PM6/17/17
to RavenDB - 2nd generation document database

Marcelo Volmaro

unread,
Jun 22, 2017, 10:29:03 AM6/22/17
to RavenDB - 2nd generation document database
Did the test work (or should I say, didn't work) for you?


On Friday, June 16, 2017 at 1:09:11 PM UTC-3, Marcelo Volmaro wrote:

Oren Eini (Ayende Rahien)

unread,
Jun 22, 2017, 2:40:57 PM6/22/17
to ravendb
Okay, found the issue. You are making this query:


The problem is that you are doing a stream over a dynamic index, and that didn't used to be supported.

We actually support this in 4.0, but we still add a 404 there, which resulted in null on the client side. 

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.

Marcelo Volmaro

unread,
Jun 22, 2017, 2:55:20 PM6/22/17
to RavenDB - 2nd generation document database
Excellent, thanks! Will wait for it then...
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages