mongodb - 大小大于 MaxDocumentSize

标签 mongodb mongodb-.net-driver

使用 MongoDB 的 10gen C# 驱动程序,在生产中每隔一段时间我就会看到这个错误:

System.IO.FileFormatException:在 C:\work\10gen\mongodb\mongo-csharp-driver\Bson\IO\BsonBinaryReader.cs 中,大小大于 MongoDB.Bson.IO.BsonBinaryReader.ReadSize() 处的 MaxDocumentSize:第556行

有没有办法使 MaxDocumentSize 变大以防止出现此错误?

我的文档大小不可能接近 16MB,我也没有存储任何文件。这是一个示例文档,当我将其保存在记事本中时,它看起来只有 13KB。

{
  "Address": "1080 DUNLAP ORPHANAGE RD",
  "Baths": null,
  "Beds": null,
  "Broker": "Crye-Leike, Inc., REALTORS |(901)840-1181",
  "City": "Unincorporated",
  "Coordinates": {
    "Latitude": 35.414949,
    "Longitude": -89.676481
  },
  "CreateDate": "Sun, 03 Apr 2011 19:40:11 GMT -04:00",
  "Description": "",
  "ExteriorConstruction": "Aluminum/Steel Siding, Double Pane Window(s), Vinyl Siding, Conventional Foundation",
  "ExteriorFeatures": "",
  "FireplaceFeatures": "In Den/Great Room, Masonry, Wood Stove Insert",
  "HasGarage": true,
  "HeatingFeatures": "Ceiling Heat, Central, Gas, Wood Stove",
  "HouseSize": null,
  "InteriorFeatures": "Double Vanity Bath, Split Bedroom Plan, BEDROOM 2: Carpet, Level 2, Walk-In Closet; BEDROOM 3: Carpet, Level 2, Walk-In Closet; BEDROOM 4: Carpet, Level 2, Private Half Bath, Walk-In Closet; Part Carpet, Part Hardwood, Sprayed Ceiling, Tile Floor, Wood Laminate Floors, Attic Access, Cable Available, Cable Wired, Central Vac, Mud Room, Walk-In Attic, Walk-In Closet(s), Breakfast Bar, Eat-In Kitchen, Pantry, Separate Dining Room, Washer/Dryer Connections, MASTER BATH: Carpet, Double Sinks, Dressing Area, Tile Floor; Gas Water Heater, Entry Hall",
  "IsActive": true,
  "ListingFeatures": [
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "Status: ACTIVE"
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "County: Tipton"
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "Approximately 10 acre(s)"
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "2 total full bath(s)"
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "2 total half bath(s)"
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "9 total rooms"
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "2 stories"
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "Type:  General Residential"
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "Master Bedroom is Carpet, Full Bath, Level 1, Walk-In Closet"
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "Basement is Partial, Unfinished"
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "Pool features:  Above Ground"
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "2 covered parking space(s)"
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "Yes car garage(s)"
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "Attached parking"
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "Cooling features:  220 Wiring, Dual System,Cooling"
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "Inclusions:  Cooktop, Dishwasher, Gas Cooking, Microwave, Refrigerator, Satellite Dish, Self Cleaning Oven"
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "Lot features:  Chain Fenced, Landscaped, Level, Some Trees, Wooded"
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "Lot size is between 10 and 20 acres"
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "Utilities present:  Public Water, Septic Tank"
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "Swimming pool(s)"
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "Basement"
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "Den"
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "Laundry room"
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "Hardwood floors"
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "Name": "Parking features:  Driveway/Pad, Garage Door Opener(s), Storage Room(s), Workshop(s)"
    }
  ],
  "ListingPhotos": [
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "OriginalPhotoUrl": "http://p.rdcpix.com/v01/l7d100943-m0x.jpg",
      "OriginalPhoto": null,
      "OriginalPhotoUpdateDate": null,
      "ThumbnailPhotoUrl": "http://p.rdcpix.com/v01/l7d100943-m0t.jpg",
      "ThumbnailPhoto": null,
      "ThumbnailPhotoUpdateDate": null
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "OriginalPhotoUrl": "http://p.rdcpix.com/v01/l7d100943-m1x.jpg",
      "OriginalPhoto": null,
      "OriginalPhotoUpdateDate": null,
      "ThumbnailPhotoUrl": "http://p.rdcpix.com/v01/l7d100943-m1t.jpg",
      "ThumbnailPhoto": null,
      "ThumbnailPhotoUpdateDate": null
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "OriginalPhotoUrl": "http://p.rdcpix.com/v01/l7d100943-m2x.jpg",
      "OriginalPhoto": null,
      "OriginalPhotoUpdateDate": null,
      "ThumbnailPhotoUrl": "http://p.rdcpix.com/v01/l7d100943-m2t.jpg",
      "ThumbnailPhoto": null,
      "ThumbnailPhotoUpdateDate": null
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "OriginalPhotoUrl": "http://p.rdcpix.com/v01/l7d100943-m3x.jpg",
      "OriginalPhoto": null,
      "OriginalPhotoUpdateDate": null,
      "ThumbnailPhotoUrl": "http://p.rdcpix.com/v01/l7d100943-m3t.jpg",
      "ThumbnailPhoto": null,
      "ThumbnailPhotoUpdateDate": null
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "OriginalPhotoUrl": "http://p.rdcpix.com/v01/l7d100943-m4x.jpg",
      "OriginalPhoto": null,
      "OriginalPhotoUpdateDate": null,
      "ThumbnailPhotoUrl": "http://p.rdcpix.com/v01/l7d100943-m4t.jpg",
      "ThumbnailPhoto": null,
      "ThumbnailPhotoUpdateDate": null
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "OriginalPhotoUrl": "http://p.rdcpix.com/v01/l7d100943-m5x.jpg",
      "OriginalPhoto": null,
      "OriginalPhotoUpdateDate": null,
      "ThumbnailPhotoUrl": "http://p.rdcpix.com/v01/l7d100943-m5t.jpg",
      "ThumbnailPhoto": null,
      "ThumbnailPhotoUpdateDate": null
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "OriginalPhotoUrl": "http://p.rdcpix.com/v01/l7d100943-m6x.jpg",
      "OriginalPhoto": null,
      "OriginalPhotoUpdateDate": null,
      "ThumbnailPhotoUrl": "http://p.rdcpix.com/v01/l7d100943-m6t.jpg",
      "ThumbnailPhoto": null,
      "ThumbnailPhotoUpdateDate": null
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "OriginalPhotoUrl": "http://p.rdcpix.com/v02/l7d100943-m7x.jpg",
      "OriginalPhoto": null,
      "OriginalPhotoUpdateDate": null,
      "ThumbnailPhotoUrl": "http://p.rdcpix.com/v02/l7d100943-m7t.jpg",
      "ThumbnailPhoto": null,
      "ThumbnailPhotoUpdateDate": null
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "OriginalPhotoUrl": "http://p.rdcpix.com/v02/l7d100943-m8x.jpg",
      "OriginalPhoto": null,
      "OriginalPhotoUpdateDate": null,
      "ThumbnailPhotoUrl": "http://p.rdcpix.com/v02/l7d100943-m8t.jpg",
      "ThumbnailPhoto": null,
      "ThumbnailPhotoUpdateDate": null
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "OriginalPhotoUrl": "http://p.rdcpix.com/v02/l7d100943-m9x.jpg",
      "OriginalPhoto": null,
      "OriginalPhotoUpdateDate": null,
      "ThumbnailPhotoUrl": "http://p.rdcpix.com/v02/l7d100943-m9t.jpg",
      "ThumbnailPhoto": null,
      "ThumbnailPhotoUpdateDate": null
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "OriginalPhotoUrl": "http://p.rdcpix.com/v02/l7d100943-m10x.jpg",
      "OriginalPhoto": null,
      "OriginalPhotoUpdateDate": null,
      "ThumbnailPhotoUrl": "http://p.rdcpix.com/v02/l7d100943-m10t.jpg",
      "ThumbnailPhoto": null,
      "ThumbnailPhotoUpdateDate": null
    },
    {
      "_id": null,
      "CreateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "UpdateDate": "Sun, 03 Apr 2011 19:40:04 GMT -04:00",
      "OriginalPhotoUrl": "http://p.rdcpix.com/v01/l7d100943-m11x.jpg",
      "OriginalPhoto": null,
      "OriginalPhotoUpdateDate": null,
      "ThumbnailPhotoUrl": "http://p.rdcpix.com/v01/l7d100943-m11t.jpg",
      "ThumbnailPhoto": null,
      "ThumbnailPhotoUpdateDate": null
    }
  ],
  "ListingPriceHistories": null,
  "ListingSalesHistories": [],
  "ListingTaxHistories": [],
  "LotSize": null,
  "MlsCreateDate": "Sat, 15 Jan 2011 19:40:04 GMT -05:00",
  "MlsId": "3215435",
  "MlsRefreshDate": "Sun, 03 Apr 2011 19:31:04 GMT -04:00",
  "Neighborhood": "Not Available",
  "Price": 290000,
  "PropertyType": "Single Family Home",
  "RealtorUrl": "http://realtor.com/realestateandhomes-detail/1080-dunlap-orphanage-rd_unincorporated_tn_38011_1124667517",
  "Roofing": "Composition Shingles",
  "State": "TN",
  "Stories": 2,
  "Style": "Traditional",
  "UpdateDate": "Sun, 03 Apr 2011 19:40:11 GMT -04:00",
  "YearBuilt": 1987,
  "ZipCode": "38011",
  "_id": {
    "$oid": "4d99055b1b9ba917bcef9443"
  }
}

最佳答案

通常,如果您的文档太大,您可能会在将它们写入数据库时​​遇到此错误,而不是在读回它们时遇到此错误。

能否提供更多信息:

  • 您使用的是哪个版本的 C# 驱动程序?
  • 您使用的是哪个版本的服务器?
  • 您知道导致此问题的文档大小吗?
  • 您能否使用 mongo shell 或其他驱动程序成功检索此文档?

如果您愿意自己构建驱动程序,您可以在抛出异常的行上设置一个断点并确定文档的大小和最大文档大小并报告这些数字。

谢谢。

关于mongodb - 大小大于 MaxDocumentSize,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6133470/

相关文章:

mongodb - 无法将 RoboMongo 与 Amazon 实例连接

MongoDB Stitch 返回数据作为 $NumberDouble 而不是数字本身

mongodb - 如何在 MongoDB 中调试存储的 javascript 函数?

c# - 如何在 MongoDB 中缓存一些临时数据?

c# - Mongodb/C# - 如何进行边界框查询?

javascript - 使用promise模块连接mongodb时出错

mongodb - 如何过滤子文档属性的聚合?

mongodb - 使用组数获取 $group 结果

c# mongoDb 2.0 字典中不存在

c# - 将数组插入 MongoDB 的子集合中会省略 _t 鉴别器