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

"String XXX is not valid UTF-8" in BSON::String since upgrading to Ruby 2.6.3 in Unicorn server

    • Type: Icon: Bug Bug
    • Resolution: Incomplete
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: bson-4.5.0
    • Component/s: None
    • None

      About 4 weeks go we upgraded from Ruby 2.5.5 to Ruby 2.6.3, and periodically get an error from our unicorn servers from code that makes a Mongoid query. The error is "ArgumentError: String XXXX is not valid UTF-8" (the XXXX part is different each time). Here's an example stack trace.

      We are following this, https://docs.mongodb.com/mongoid/master/tutorials/mongoid-configuration/#usage-with-forking-servers. I haven't seen the issue occur on our Ruby code that isn't a web server.

      These errors happen very sporadically, and it seems to be that once a server gets one of these errors it'll keep happening until we restart it. We're seeing this happen about 3 times per week but have not been able to figure out a way to reproduce.

      Running bson 4.5.0 and mongo-ruby-driver 2.10.0

      ArgumentError: String zU is not valid UTF-8.
      from bson/string.rb:49:in `put_string'
      from bson/string.rb:49:in `to_bson'
      from bson/hash.rb:42:in `put_hash'
      from bson/hash.rb:42:in `to_bson'
      from mongo/protocol/serializers.rb:326:in `serialize'
      from mongo/protocol/serializers.rb:241:in `serialize'
      from mongo/protocol/serializers.rb:171:in `block in serialize'
      from mongo/protocol/serializers.rb:168:in `each'
      from mongo/protocol/serializers.rb:168:in `serialize'
      from mongo/protocol/message.rb:237:in `block in serialize_fields'
      from mongo/protocol/message.rb:225:in `each'
      from mongo/protocol/message.rb:225:in `serialize_fields'
      from mongo/protocol/message.rb:126:in `serialize'
      from mongo/protocol/msg.rb:126:in `serialize'
      from mongo/operation/shared/sessions_supported.rb:166:in `block in build_message'
      from mongo/operation/shared/sessions_supported.rb:161:in `tap'
      from mongo/operation/shared/sessions_supported.rb:161:in `build_message'
      from mongo/operation/shared/executable.rb:52:in `block in dispatch_message'
      from mongo/server/connection_pool.rb:550:in `with_connection'
      from mongo/server.rb:401:in `with_connection'
      from mongo/operation/shared/executable.rb:51:in `dispatch_message'
      from mongo/operation/shared/executable.rb:46:in `get_result'
      from mongo/operation/shared/executable.rb:26:in `block (2 levels) in do_execute'
      from mongo/operation/shared/specifiable.rb:587:in `add_error_labels'
      from mongo/operation/shared/executable.rb:25:in `block in do_execute'
      from mongo/operation/shared/unpinnable.rb:30:in `unpin_maybe'
      from mongo/operation/shared/executable.rb:24:in `do_execute'
      from mongo/operation/shared/executable.rb:34:in `execute'
      from mongo/operation/shared/op_msg_or_find_command.rb:28:in `execute'
      from mongo/collection/view/iterable.rb:89:in `send_initial_query'
      from mongo/collection/view/iterable.rb:46:in `block in each'
      from mongo/retryable.rb:61:in `block in read_with_retry_cursor'
      from mongo/retryable.rb:317:in `legacy_read_with_retry'
      from mongo/retryable.rb:119:in `read_with_retry'
      from mongo/retryable.rb:60:in `read_with_retry_cursor'
      from forwardable.rb:230:in `read_with_retry_cursor'
      from mongo/collection/view/iterable.rb:45:in `each'
      from mongoid/query_cache.rb:222:in `each'
      from mongoid/contextual/mongo.rb:133:in `each'
      from mongoid/contextual/mongo.rb:325:in `map'
      from mongoid/contextual/mongo.rb:325:in `map'
      from mongoid/contextual.rb:20:in `map'

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            jonhyman Jon Hyman
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: