-
Type: Bug
-
Resolution: Fixed
-
Priority: Minor - P4
-
None
-
Affects Version/s: 2.4.2
-
Component/s: None
-
None
-
Environment:Ruby: 2.4.0
Mongo gem: 2.4.2
Mongodb: Sharded DB running MongoDB v. 3.4.6
mongos and ruby code are running on the same host, connection to mongos is through localhost
Read/write operation on sharded collection occasionally throw TypeError exception. As the errors occur randomly, every few 100s of thousands of calls, it's difficult to provide a working example reliably triggering the bug.
Subsequent invocation of the operation with the same arguments always results in successful execution. As a temporary workaround the following code has been used:
retrying = false begin result = @collection.insert_many(data) #found_ids = @collection.find({:id => {'$in' => ids}},:projection => {:id => 1, :_id => 0}).to_a; #result = @collection.update_one({:id => j[:id]}, {'$set' => j}, {:upsert => true}) rescue => e log_error "#{(retrying)?"***RETRY***":"*will retry*"} Exception: #{e.inspect}\nBacktrace:\n#{e.backtrace.join("\n\t").sub("\n\t", ": #{e}#{e.class ? " (#{e.class})" : ''}\n\t")}\n" unless retrying retrying = true retry else log_error "***REDO*** Exception occurred in second iteration." end retrying = false end
Exception occurring while reading data:
/home/j/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/forwardable.rb:228:in `max_message_size': wrong argument type Integer (expected Proc) (TypeError)
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/server/connection.rb:195:in `block in write'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/server/connection.rb:192:in `each'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/server/connection.rb:192:in `write'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/server/connection.rb:162:in `deliver'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/server/connection.rb:108:in `block in dispatch'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/monitoring/publishable.rb:47:in `publish_command'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/server/connection.rb:107:in `dispatch'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/operation/executable.rb:37:in `block in execute'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/server/connection_pool.rb:107:in `with_connection'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/server.rb:242:in `with_connection'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/operation/executable.rb:35:in `execute'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/collection/view/iterable.rb:81:in `send_initial_query'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/collection/view/iterable.rb:41:in `block in each'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/retryable.rb:43:in `read_with_retry'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/collection/view/iterable.rb:39:in `each'
../../prog.rb:271:in `to_a'
../../prog.rb:271:in `b_import_data'
../../prog:561:in `<main>'
Exception occurring in insert_many:
/home/j/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/forwardable.rb:228:in `cluster': wrong argument type Integer (expected Proc) (TypeError)
/home/j/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/forwardable.rb:222:in `next_primary'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/bulk_write.rb:58:in `block in execute'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/retryable.rb:104:in `write_with_retry'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/bulk_write.rb:56:in `execute'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/collection.rb:401:in `bulk_write'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/collection.rb:379:in `insert_many'
../../prog:277:in `b_import_data'
../../prog.rb:544:in `<main>'
There are two exception scenarios for update_one
/home/j/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/forwardable.rb:228:in `max_message_size': wrong argument type Integer (expected Proc) (TypeError)
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/server/connectable.rb:114:in `block in read'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/server/connectable.rb:97:in `ensure_connected'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/server/connectable.rb:113:in `read'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/server/connection.rb:163:in `deliver'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/server/connection.rb:108:in `block in dispatch'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/monitoring/publishable.rb:47:in `publish_command'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/server/connection.rb:107:in `dispatch'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/operation/write/command/writable.rb:39:in `block in execute'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/server/connection_pool.rb:107:in `with_connection'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/server.rb:242:in `with_connection'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/operation/write/command/writable.rb:38:in `execute'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/operation/write/write_command_enabled.rb:57:in `execute_write_command'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/operation/write/write_command_enabled.rb:41:in `execute'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/collection/view/writable.rb:244:in `block in update'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/retryable.rb:104:in `write_with_retry'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/collection/view/writable.rb:234:in `update'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/collection/view/writable.rb:209:in `update_one'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/collection.rb:523:in `update_one'
../../prog.rb:141:in `import_data'
../../prog.rb:367:in `<main>'
/home/j/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/forwardable.rb:228:in `cluster': wrong argument type Integer (expected Proc) (TypeError)
/home/j/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/forwardable.rb:222:in `next_primary'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/collection/view/writable.rb:235:in `block in update'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/retryable.rb:104:in `write_with_retry'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/collection/view/writable.rb:234:in `update'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/collection/view/writable.rb:209:in `update_one'
/home/j/.rvm/gems/ruby-2.4.0/gems/mongo-2.4.2/lib/mongo/collection.rb:523:in `update_one'
../../prog.rb:141:in `import_data'
../../prog.rb:367:in `<main>'
Mongos log file does not contain any error messages.
- duplicates
-
RUBY-1194 TypeError: wrong argument type Integer (expected Proc) with MRI 2.4
- Closed