New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RUBY-2234 Fix error on large bulk writes with zlib #2026
Conversation
…k writes split correctly
lib/mongo/server/connection_base.rb
Outdated
@@ -213,12 +212,21 @@ def serialize(message, client, buffer = BSON::ByteBuffer.new) | |||
max_bson_size += MAX_BSON_COMMAND_OVERHEAD | |||
end | |||
|
|||
final_message.serialize(buffer, max_bson_size) | |||
temp_buffer = BSON::ByteBuffer.new | |||
temp_buffer.put_string(buffer.to_s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this should be put_bytes
and could you add a comment that this copies the existing passed in buffer contents, if any.
I broke jruby, so please disregard for now :) |
if max_message_size | ||
# Create a separate buffer that contains the un-compressed message | ||
# for the purpose of checking its size. Write any pre-existing contents | ||
# from the original buffer into the temporary one. | ||
temp_buffer = BSON::ByteBuffer.new | ||
|
||
# TODO: address the fact that this line mutates the buffer. | ||
temp_buffer.put_bytes(buffer.get_bytes(buffer.length)) | ||
|
||
message.serialize(temp_buffer, max_bson_size) | ||
if temp_buffer.length > max_message_size | ||
raise Error::MaxMessageSize.new(max_message_size) | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@p-mongo is this what you had in mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Yep looks good.
No description provided.