-
Notifications
You must be signed in to change notification settings - Fork 455
CDRIVER-3964 Append session to all operations in UTR #798
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
Conversation
As for bulk writes, the session option should be added directly to the
This looks like an oversight and should be reported as a new ticket. One possible workaround would be to forgo @kevinAlbs Is this something worth addressing for the 5.0-compat release? Otherwise, I suppose we'll need to skip any tests that use |
@@ -764,7 +847,7 @@ operation_distinct (test_t *test, | |||
"{", | |||
&filter, | |||
"}"); | |||
bson_concat (distinct, bson_parser_get_extra (parser)); | |||
bson_concat (distinct, opts); |
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 don't think this works. mongoc_client_session_append
is going to append a "sessionId" to opts
, but that's only the internal libmongoc identifier and should not end up in the raw command document being sent to the server.
This test currently uses mongoc_collection_command_simple
, which doesn't support sessions. I think you'll need to change it to use mongoc_database_read_command_with_opts
instead. And in doing so, you should pass opts
as its own parameter (removing bson_concat
entirely).
FWIW, operation_distinct
appears to be the only operation to use mongoc_collection_command_simple
so I don't think this is a concern anywhere else.
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.
Gotcha, thanks for the guidance. I believe you meant mongoc_collection_read_command_with_opts
, so I switched to that with a separate opts
parameter and no bson_concat
.
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 was definitely referring to mongoc_database_read_command_with_opts
. I forgot there were similarly named collection methods, but if you look at both functions you'll see they're just syntactic sugar for _mongoc_client_command_with_opts
.
In my mind, commands are scoped to a database, not a collection, so I don't think about having a helper at the collection level. The command itself may refer to a collection name (e.g. find: <name>
), but that's still something you'd have to manually specify in the command document.
Anywho, either method should work. And since distinct
is a collection-level operation, it makes sense that you'll already have the necessary collection object on hand here.
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.
Ah gotcha! I'll just use the mongoc_collection_read_command_with_opts
since I have the collection handle already.
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.
Sorry for not bringing this up sooner, but re-reading this changing I now wonder if operation_distinct
should be implemented at all if libmongoc doesn't actually provide a helper method for it.
@kevinAlbs: Any thoughts on this? Looking at operation_run
in operation.c
, it appears that an error will be thrown for unsupported operations in lieu of skipping the test. That seems odd given my experience with retryable reads, where drivers tend to skip tests for unsupported read operations (e.g. optional collection or database enumeration methods).
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.
Good point. As it is, operation_distinct
does not really test any C driver functionality (and I don't think it's documented that users should create their own distinct in this manner).
The Go and CXX test runners also error on unsupported operations. I think it would be ok to skip distinct
tests since the C driver has no helper, but always skipping on unsupported operations might make it harder to recognize when a new operation requires a new case in the test runner.
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'd be OK with leaving this as-is and then opening a separate CDRIVER issue to follow-up. That issue can propose an explicit skip for tests utilizing distinct
operations. Alternatively, you might decide to utilize the is_test_skipped
function I'm adding in #801 and just explicitly add tests using distinct
to that list.
Either way, I think it makes sense to figure out how we want to handle this before the retryable read tests get ported and we need to skip its tests for unsupported operations (e.g. collection enumeration variants). In that case, the explicit list in is_test_skipped
probably makes the most sense.
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.
Filed CDRIVER-4024. Using something like is_test_skipped
seems best to me; then we can explicitly list the tests with unsupported operations like distinct
or collection enumeration variants. Leaving operation_distinct
as-is for now, though.
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.
Appended session to operation_list_databases
; I just needed to make sure op->arguments
wasn't NULL before appending it to opts
.
Per the discussion here, bulk_op_append
does not need a session appension since it's already appended in operation_bulk_write
.
The operation_find_and_*
tests still have no session appension, but I'll file a ticket to add a session option to mongoc_find_and_modify_opts_t
.
@@ -764,7 +847,7 @@ operation_distinct (test_t *test, | |||
"{", | |||
&filter, | |||
"}"); | |||
bson_concat (distinct, bson_parser_get_extra (parser)); | |||
bson_concat (distinct, opts); |
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.
Gotcha, thanks for the guidance. I believe you meant mongoc_collection_read_command_with_opts
, so I switched to that with a separate opts
parameter and no bson_concat
.
It's funky, but session options can be passed by first appending the session with |
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
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.
One question in #798 (comment), but LGTM otherwise.
CDRIVER-3964
Appends session to all possible operations in the unified test runner.
Not all operations seem to take the
session
option. I noticed thatoperation_list_databases
andbulk_op_append
cause errors ifsession
is appended, and theoperation_find_one_and_*
operations cannot take a session option since they usemongoc_find_and_modify_opts_t *
instead ofbson_t *
as their options param. Let me know if you think I missed an operation/some operation does not need thesession
option.