Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-568

BSON::InvalidDocument: Document too large on update

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • 1.8.5
    • Affects Version/s: 1.8.3
    • Component/s: None
    • Labels:
      None
    • Environment:
      heroku and mongolabs

      Possibly related: https://jira.mongodb.org/browse/RUBY-526?focusedCommentId=288113#comment-288113

      We upgraded from mongodb 2.0.x to 2.2.3 via mongolabs, and in the process upgraded mongo and bson_ext from 1.8.1 to 1.8.3. We're also using mongoid 2.5.1 and have not upgraded that - though as far as I can see mongoid isn't a part of the equation.

      After the mongo/bson_ext/mongodb upgrade, we started seeing the errors below on actions that're essentially unchanged and that worked previously.

      CrowdTasksController# (BSON::InvalidDocument) "Document too large: This BSON document is limited to 4194304 bytes."
       
      /app/vendor/bundle/ruby/1.9.1/gems/bson-1.8.3/lib/bson/bson_c.rb:6:in `serialize'
      /app/vendor/bundle/ruby/1.9.1/gems/bson-1.8.3/lib/bson/bson_c.rb:6:in `serialize'
      /app/vendor/bundle/ruby/1.9.1/gems/mongo-1.8.3/lib/mongo/collection.rb:471:in `update'
      /app/vendor/bundle/ruby/1.9.1/gems/mongoid-2.5.1/lib/mongoid/collections/master.rb:25:in `block in update'
      /app/vendor/bundle/ruby/1.9.1/gems/mongoid-2.5.1/lib/mongoid/collections/retry.rb:29:in `retry_on_connection_failure'
      /app/vendor/bundle/ruby/1.9.1/gems/mongoid-2.5.1/lib/mongoid/collections/master.rb:24:in `update'
      /app/vendor/bundle/ruby/1.9.1/gems/mongoid-2.5.1/lib/mongoid/collection.rb:149:in `update'
      /app/vendor/bundle/ruby/1.9.1/gems/mongoid-2.5.1/lib/mongoid/persistence/operations/update.rb:45:in `block in persist'
      /app/vendor/bundle/ruby/1.9.1/gems/mongoid-2.5.1/lib/mongoid/persistence/modification.rb:25:in `block (2 levels) in prepare'
      /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:390:in `_run_update_callbacks'
      /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:81:in `run_callbacks'
      /app/vendor/bundle/ruby/1.9.1/gems/mongoid-2.5.1/lib/mongoid/callbacks.rb:61:in `run_callbacks'
      /app/vendor/bundle/ruby/1.9.1/gems/mongoid-2.5.1/lib/mongoid/persistence/modification.rb:24:in `block in prepare'
      /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:428:in `_run_save_callbacks'
      /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:81:in `run_callbacks'
      /app/vendor/bundle/ruby/1.9.1/gems/mongoid-2.5.1/lib/mongoid/callbacks.rb:61:in `run_callbacks'
      /app/vendor/bundle/ruby/1.9.1/gems/mongoid-2.5.1/lib/mongoid/persistence/modification.rb:23:in `prepare'
      /app/vendor/bundle/ruby/1.9.1/gems/mongoid-2.5.1/lib/mongoid/persistence/operations/update.rb:43:in `persist'
      /app/vendor/bundle/ruby/1.9.1/gems/mongoid-2.5.1/lib/mongoid/persistence.rb:91:in `update'
      /app/vendor/bundle/ruby/1.9.1/gems/mongoid-2.5.1/lib/mongoid/persistence.rb:156:in `upsert'
      /app/vendor/bundle/ruby/1.9.1/gems/mongoid-2.5.1/lib/mongoid/persistence.rb:75:in `save!'
      /app/lib/task_action_processor/query_result_cleanup.rb:31:in `block in handle'
      

      I'm not really a C guy, but these lines seem potentially relevant:

      https://github.com/mongodb/mongo-ruby-driver/blob/1.8.3/ext/cbson/cbson.c#L604:L610

      I've forked the driver and brute-forced max_bson_size to 16mb everywhere that made sense to me:
      https://github.com/Shopximity/mongo-ruby-driver/commit/4dce8279db20b2f4214681bba75a24d1e25eb098

      I'll report back if this fixes the problem or not.

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            djcp Dan Collis-Puro
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: