Skip to content
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

Merged
merged 8 commits into from Jul 29, 2020
Merged

RUBY-2234 Fix error on large bulk writes with zlib #2026

merged 8 commits into from Jul 29, 2020

Conversation

egiurleo
Copy link
Contributor

No description provided.

@egiurleo egiurleo changed the title [wip] RUBY-2234 Fix error on large bulk writes with zlib RUBY-2234 Fix error on large bulk writes with zlib Jul 22, 2020
@egiurleo egiurleo requested a review from p-mongo July 22, 2020 18:40
@@ -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)
Copy link
Contributor

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.

@egiurleo
Copy link
Contributor Author

I broke jruby, so please disregard for now :)

@egiurleo egiurleo requested a review from p-mongo July 27, 2020 17:00
lib/mongo/server/connection_base.rb Show resolved Hide resolved
lib/mongo/server/connection_base.rb Outdated Show resolved Hide resolved
lib/mongo/server/connection_base.rb Outdated Show resolved Hide resolved
Comment on lines +226 to 239
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
Copy link
Contributor Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Yep looks good.

@egiurleo egiurleo merged commit d83ca98 into mongodb:master Jul 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants