-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Implement splitting and encoding ops
, nsInfo
as separate OP_MSG
sections, implement prose tests
#1495
Implement splitting and encoding ops
, nsInfo
as separate OP_MSG
sections, implement prose tests
#1495
Conversation
…nstructor JAVA-5527
JAVA-5527
JAVA-5527
JAVA-5527
JAVA-5528
…lientWriteModel` subtypes JAVA-5527
JAVA-5528
JAVA-5528
JAVA-5527
…ommandWriteConcern` to `CommandOperationHelper` JAVA-5528
Justification: this is the only operation that uses a lazy document for the command. It was only lazy in the first place because of the lack of splitting in the initial implementation, but now that there is splitting there is no longer a need, and the fact that it's an outlier would make it confusing for future readers. JAVA-5529 Co-authored-by: Jeff Yemin <jeff.yemin@mongodb.com>
This makes `CommandMessage` generic for any command with two sequences. The new abstraction adds: * The sequence identifiers for each sequence. * A field name validator for both sequences. * A `List<BsonElement>`` for any extra elements required by the splitting logic, so that `txnNumber` doesn't have to be treated specially. Make `SplittablePayload` extend `OpMsgSequence`. This brings SplittablePayload closer in design to `DualMessageSequences`, reducing a potential source of confusion for future readers. JAVA-5529 Co-authored-by: Jeff Yemin <jeff.yemin@mongodb.com>
@jyemin I incorporated the changes you proposed. See ea0633e, 9fe35e4. However, I did not include jyemin@7d7f3eb, because as I understand it. |
I think the difference is that the checks you enumerated apply equally to all commands: no command document can be larger than maxDocumentSize + DOCUMENT_HEADROOM, period. Whereas for Also, wanted to check about jyemin@a2805a6, since you didn't mention that commit. |
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.
Waiting for feedback from Valentin
Each time I look at this, I not only can't see a problem with the current approach, but even fail to convince myself that the proposed change makes things better overall.
The logic that is aware of which documents are stored, and which ones are not, is in
The logic that is aware of acknowledged writes and of what an application has requested, is in If for some reason we want |
JAVA-5529 Co-authored-by: Jeff Yemin <jeff.yemin@mongodb.com>
driver-core/src/main/com/mongodb/internal/connection/CommandMessage.java
Outdated
Show resolved
Hide resolved
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.
Latest commit LGTM.
Not sure if any more are coming in this PR so not approving the PR yet.
…ulk write operation JAVA-5695
@vbabanin This PR is ready for your review. |
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.
LGTM (again!)
driver-core/src/main/com/mongodb/internal/connection/CommandMessage.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/CommandMessage.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/CommandMessage.java
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/BsonWriterHelper.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/BsonWriterHelper.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/CommandMessage.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/CommandMessage.java
Outdated
Show resolved
Hide resolved
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.
Thanks for moving these to constants— makes the code easier to read!
driver-core/src/main/com/mongodb/internal/connection/CommandMessage.java
Outdated
Show resolved
Hide resolved
BsonBinaryWriter firstWriter = createBsonBinaryWriter(firstOutput, dualMessageSequences.getFirstFieldNameValidator(), null); | ||
BsonBinaryWriter secondWriter = createBsonBinaryWriter(secondOutput, dualMessageSequences.getSecondFieldNameValidator(), null); | ||
// the size of operation-agnostic command fields (a.k.a. extra elements) is counted towards `messageOverheadInBytes` | ||
int messageOverheadInBytes = 1000; |
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.
Does this limitation apply only to client bulk write
?
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 am not sure if limitation is the right word here. But yes, this is unique to client bulk writes:
- A mixed bulk write does not mix different kinds of operations in a batch because it is technically impossible there. As a result, we know in advance what kind of operations is in a batch, thus knowing whether it supports retries or not. That allows us to encode
extraElements
before encoding thePAYLOAD_TYPE_1_DOCUMENT_SEQUENCE
section. Thus, when we are encoding the document sequence, we know exactly how much space we have left available before reachingMessageSettings.getMaxMessageSize
. - A client bulk write may mix different kinds of operations in a batch, which means that we know whether the batch supports retries only after encoding its
PAYLOAD_TYPE_1_DOCUMENT_SEQUENCE
sections. That is, we may need to write something after writing those sections. That, in turn, means we can't know exactly how much space we have left when we encode document sequences. But whatever we write after writing the sequences, its size is bounded, and 1000 bytes is used in the spec as the value that is definitely not smaller than that bound.
driver-core/src/main/com/mongodb/internal/operation/ClientBulkWriteOperation.java
Show resolved
Hide resolved
…ssage.java Add `this.` to align with the code style in the `CommandMessage` constructor Co-authored-by: Viacheslav Babanin <frest0512@gmail.com>
…geBodyWithMetadata`
Thank you, @vbabanin, all your refactoring suggestions were really good. |
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.
LGTM!
b0e2bdf
into
mongodb:JAVA-4586_bulk-write
The first four commits are well-organized to allow reviewing them one by one.
This PR depends on #1486.
The following test runners execute the unified and prose tests added in this PR:
com.mongodb.client.CrudProseTest
com.mongodb.client.AbstractClientSideOperationsTimeoutProseTest
JAVA-5529
JAVA-5610
JAVA-5695