超时检索文档

时间:2014-08-21 08:55:39

标签: mongodb mongodb-.net-driver mongo-c-driver

有时我们在尝试获取特定文档时会收到此错误消息:

System.IO.IOException: Unable to read data from the transport connection: 
A connection attempt failed because the connected party did not properly 
respond after a period of time, or established connection failed because 
connected host has failed to respond. 

---> System.Net.Sockets.SocketException: A connection attempt failed because the 
connected party did not properly respond after a period of time, or established 
connection failed because connected host has failed to respond
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)

--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at MongoDB.Bson.IO.ByteBufferFactory.LoadFrom(Stream stream)
at MongoDB.Driver.Internal.MongoConnection.ReceiveMessage[TDocument] (BsonBinaryReaderSettings readerSettings, IBsonSerializer serializer, IBsonSerializationOptions serializationOptions)
at MongoDB.Driver.Operations.QueryOperation`1.GetFirstBatch(IConnectionProvider connectionProvider)
at MongoDB.Driver.Operations.QueryOperation`1.Execute(IConnectionProvider connectionProvider)
at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
at ... Linq statement in our code

最近刚刚保存的文档似乎发生了。

如果我运行查询以从Web服务器获取MongoDB shell中的此文档,它就会挂起。获取包括此文档在内的所有文档都可以正常运行。

如果我从另一台机器运行相同的查询,一切都很好。

解决此问题的唯一方法是从另一台计算机更改此特定文档的一个属性。

环境:

  • Windows Server 2012上的MongoDB v2.6.3。
  • Windows Server 2008 R2上的C#/ asp.net
  • mongocsharpdriver版本1.9.2。

在Mongo Shell中运行查询的Web服务器上的进程监视器屏幕转储:Process monitor shows that TCP Send is done but no TCP receive

从一台服务器挂起的示例文档/ json

    {
    "_id": "a635399137391923437",
    "Title": "Confectionery & Snacks",
    "NavigationAreas": {
        "Items": {
            "TopMenu": {
                "_id": "TopMenu",
                "Items": [
                    {
                        "Title": "C. Library",
                        "Url": "/ActivityOwnerDashboard/Index?activityOwnerDashboardId=a634395044701382271&activityownerId={activityownerId\n}&language={language}",
                        "Enable": true,
                        "IsPublic": true,
                        "VisibleToRoles": [
                            "Members",
                            "Editor",
                            "Administrators",
                            "Agency1",
                            "Agency2",
                            "Corporatemembers"
                        ]
                    },
                    {
                        "Title": "T. Monitors",
                        "Url": "/Dashboard/Index?dashboardId=a635073303205437766&activityownerId={activityownerId}&language={langu\nage}",
                        "Enable": true,
                        "IsPublic": true,
                        "VisibleToRoles": [
                            "Members",
                            "Editor",
                            "Administrators",
                            "Agency1",
                            "Agency2",
                            "Corporatemembers"
                        ]
                    },
                    {
                        "Title": "Administration",
                        "Url": "/ActivityOwnerDashboard/Index?activityOwnerDashboardId=a634988042201870012&activityownerId={activityownerId}&language={\nlanguage}",
                        "Enable": true,
                        "IsPublic": true,
                        "VisibleToRoles": [
                            "Editor",
                            "Administrators",
                            "Agency1",
                            "Agency2"
                        ]
                    },
                    {
                        "Title": "KPI Monitors",
                        "Url": "/Dashboard/Index?dashboardId=a635288464367511308&activityownerId={activityOwnerId}&language={language}",
                        "Enable": true,
                        "IsPublic": true,
                        "VisibleToRoles": [
                            "Members",
                            "Editor",
                            "Administrators",
                            "Agency1",
                            "Agency2",
                            "Corporatemembers"
                        ]
                    }
                ]
            }
        }
    },
    "Timestamp": NumberLong("6354421106745")
}

0 个答案:

没有答案