From a0fb72acffa9c5d9cb4ee5d9e99f35b3de21c9e9 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 30 Jan 2020 16:04:38 -0500 Subject: [PATCH 1/4] Spelling fixes --- lib/mongo/protocol/msg.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mongo/protocol/msg.rb b/lib/mongo/protocol/msg.rb index 35f64e377b..499907691d 100644 --- a/lib/mongo/protocol/msg.rb +++ b/lib/mongo/protocol/msg.rb @@ -92,7 +92,7 @@ def payload # https://jira.mongodb.org/browse/RUBY-1591. # Note that even without the reordering, the payload is not an exact # match to what is sent over the wire because the command as used in - # the published eent combines keys from multiple sections of the + # the published event combines keys from multiple sections of the # payload sent over the wire. ordered_command = {} skipped_command = {} @@ -110,7 +110,7 @@ def payload database_name: global_args[DATABASE_IDENTIFIER], command: ordered_command, request_id: request_id, - reply: sections[0] + reply: sections[0], ) end From 7ccb3416df466103538f032b2fafae751066f3a0 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 30 Jan 2020 16:18:22 -0500 Subject: [PATCH 2/4] Fix docstrings referring to options on protocol messages --- lib/mongo/protocol/insert.rb | 4 +++- lib/mongo/protocol/msg.rb | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/mongo/protocol/insert.rb b/lib/mongo/protocol/insert.rb index ad856fa2f6..1e4fd7ef63 100644 --- a/lib/mongo/protocol/insert.rb +++ b/lib/mongo/protocol/insert.rb @@ -46,8 +46,10 @@ class Insert < Message # @param options [Hash] Additional options for the insertion. # # @option options :flags [Array] The flags for the insertion message. - # # Supported flags: +:continue_on_error+ + # @option options [ true, false ] validating_keys Whether keys should be + # validated for being valid document keys (i.e. not begin with $ and + # not contain dots). def initialize(database, collection, documents, options = {}) @database = database @namespace = "#{database}.#{collection}" diff --git a/lib/mongo/protocol/msg.rb b/lib/mongo/protocol/msg.rb index 499907691d..7923658e77 100644 --- a/lib/mongo/protocol/msg.rb +++ b/lib/mongo/protocol/msg.rb @@ -44,16 +44,17 @@ class Msg < Message # { type: 1, payload: { identifier: 'documents', sequence: [..] } }) # # @param [ Array ] flags The flag bits. Current supported values - # are :more_to_come and :checksum_present. - # @param [ Hash ] options The options. There are currently no supported - # options, this is a placeholder for the future. + # are :more_to_come and :checksum_present. + # @param [ Hash ] options The options. # @param [ BSON::Document, Hash ] global_args The global arguments, # becomes a section of payload type 0. # @param [ BSON::Document, Hash ] sections Zero or more sections, in the format # { type: 1, payload: { identifier: , sequence: > } } or # { type: 0, payload: } # - # @option options [ true, false ] validating_keys Whether keys should be validated. + # @option options [ true, false ] validating_keys Whether keys should be + # validated for being valid document keys (i.e. not begin with $ and + # not contain dots). # # @api private # From 74acc21c148b3ee69b4b2a6380f658a0b2c3ddaa Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 30 Jan 2020 17:02:24 -0500 Subject: [PATCH 3/4] Report pool max size in the exception message when failing to check out a connection --- lib/mongo/server/connection_pool.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/mongo/server/connection_pool.rb b/lib/mongo/server/connection_pool.rb index a3e1138943..4facc55241 100644 --- a/lib/mongo/server/connection_pool.rb +++ b/lib/mongo/server/connection_pool.rb @@ -347,7 +347,8 @@ def check_out "from pool for #{@server.address} after #{wait_timeout} sec. " + "Connections in pool: #{@available_connections.length} available, " + "#{@checked_out_connections.length} checked out, " + - "#{@pending_connections.length} pending" + "#{@pending_connections.length} pending " + + "(max size: #{max_size})" end raise Error::ConnectionCheckOutTimeout.new(msg, address: @server.address) end From d0b41982c1002b6f40854b16ecd22e0b38b3224a Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Fri, 31 Jan 2020 16:13:32 -0500 Subject: [PATCH 4/4] Rename inflate! to maybe_inflate because it does not always inflate --- lib/mongo/protocol/compressed.rb | 8 +++----- lib/mongo/protocol/message.rb | 11 ++++++----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/mongo/protocol/compressed.rb b/lib/mongo/protocol/compressed.rb index d2e5cb7d78..9223e67307 100644 --- a/lib/mongo/protocol/compressed.rb +++ b/lib/mongo/protocol/compressed.rb @@ -60,15 +60,13 @@ def initialize(message, compressor, zlib_compression_level = nil) @request_id = message.request_id end - # Inflate an OP_COMRESSED message and return the original message. - # - # @example Inflate a compressed message. - # message.inflate! + # Inflates an OP_COMRESSED message and returns the original message. # # @return [ Protocol::Message ] The inflated message. # # @since 2.5.0 - def inflate! + # @api private + def maybe_inflate message = Registry.get(@original_op_code).allocate uncompressed_message = Zlib::Inflate.inflate(@compressed_message) diff --git a/lib/mongo/protocol/message.rb b/lib/mongo/protocol/message.rb index f5f81e05c7..93627a7155 100644 --- a/lib/mongo/protocol/message.rb +++ b/lib/mongo/protocol/message.rb @@ -129,13 +129,14 @@ def maybe_compress(compressor, zlib_compression_level = nil) end end - # Inflate a message. + # Inflate a message if it is compressed. # - # @return [ self ] Always returns self. Other message types should - # override this method. + # @return [ Protocol::Message ] Always returns self. Subclasses should + # override this method as necessary. # # @since 2.5.0 - def inflate! + # @api private + def maybe_inflate self end @@ -183,7 +184,7 @@ def self.deserialize(io, max_message_size = MAX_MESSAGE_SIZE, expected_response_ deserialize_field(message, buffer, field) end end - message.inflate! + message.maybe_inflate end # Tests for equality between two wire protocol messages