【问题标题】:Odd exception with Raven DB Bulk InsertRaven DB 批量插入的奇怪异常
【发布时间】:2015-06-23 16:26:58
【问题描述】:

我目前正在试验 RavenDB (3.0) 并尝试使用批量插入功能。但是,尽管批量插入似乎可以工作,但在完成后我仍然收到异常:

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.

堆栈跟踪是

   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()

这是我的代码:

 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();
     }
 }

奇怪的是数据正在被写入数据库(我可以在数据库浏览器中查看),而且我的代码中没有捕获到异常 - 它被标记为未处理,尽管try/catch。

我对为什么会发生这种情况感到困惑,更重要的是,我不知道如何防止它发生。有人有什么想法吗?

【问题讨论】:

    标签: exception ravendb ravendb-http


    【解决方案1】:

    该异常来自我们用于批量插入的手表。完成后,我们关闭手表,并抛出异常。 它在内部处理,不会对您的应用程序产生任何影响

    【讨论】:

    • 感谢您的澄清,那我就忽略它:)
    猜你喜欢
    • 1970-01-01
    • 2012-07-03
    • 2015-09-29
    • 1970-01-01
    • 2019-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-02
    相关资源
    最近更新 更多