Odd exception with Raven DB Bulk Insert

444 views Asked by At

I'm experimenting with RavenDB (3.0) at the moment and trying to use the Bulk Insert feature. However although the bulk insert appears to work, I keep getting an exception right after it finishes:

An exception of type 'System.IO.EndOfStreamException' occurred in Raven.Client.Lightweight.dll but was not handled in user code

Additional information: Attempted to read past the end of the stream.

Stack trace is

   at Raven.Client.Connection.ObservableLineStream.<Start>b__1(Task`1 task) in c:\Builds\RavenDB-Stable-3.0\Raven.Client.Lightweight\Connection\ObservableLineStream.cs:line 39
   at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()

This is the code I have:

 static void Main(string[] args)
 {
     try
     {
        using (var store = new DocumentStore {
                     Url = "http://localhost:8080/", 
                     DefaultDatabase = "Northwind" })
         {
             store.Initialize();
             int total = 10000;
             using (var bulkInsert = store.BulkInsert())
             {
                for (int i = 0; i < total; i++){
                     bulkInsert.Store(new Employee{
                             FirstName = "FirstName #" + i,
                             LastName = "LastName #" + i});
                        }                           
                    }
                }
            }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
     finally
     {
         Console.ReadLine();
     }
 }

What's odd is that the data is being written to the database (I can view it in the database browser), but also that the exception isn't being caught in my code - it's flagged as unhandled, despite the try/catch.

I'm flummoxed as to why it might be happening, and more importantly, how I can prevent it. Anyone have any ideas?

1

There are 1 answers

1
Ayende Rahien On BEST ANSWER

That exception is from the watch that we use for the bulk insert. When it is done, we close the watch, and the exception is thrown. It is handled internally, and shouldn't have any affect on your application