-
Notifications
You must be signed in to change notification settings - Fork 548
CXX-1998 'CommitQuorum' option support for 'createIndexes’ command on MongoDB 4.4 #691
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
|
@kevinAlbs I see you closed CDRIVER-3627. From the spec:
I'm not sure if this was missed in C or it was decided that we shouldn't do it. This implementation doesn't currently throw an error for server version less than 4.4. If we decided against it in C then I'll add it here but if it was left out we should probably throw an error from libmongoc. |
Codecov Report
@@ Coverage Diff @@
## master #691 +/- ##
==========================================
- Coverage 85.79% 83.61% -2.18%
==========================================
Files 346 346
Lines 15521 16009 +488
==========================================
+ Hits 13316 13386 +70
- Misses 2205 2623 +418
Continue to review full report at Codecov.
|
It was not applicable for libmongoc. The only index creation helpers in libmongoc are deprecated (and not used by the C++ driver), and the generic command helpers should not be inspecting the command options. To do the wire version check in the C++ driver, the only way I see is to use libmongoc's TBH it seems like a very roundabout way for this check, but it also might be the best option we have right now. This is an unfortunate consequence of libmongoc not providing index helpers, it pushes more work onto wrapping drivers :/ I think this would be an argument for adding index helpers to libmongoc. I do not know the rationale for why they were deprecated originally. Edit: Thinking about this a bit more, even if it is an exception, checking the wire version constraint may be worth doing in libmongoc. I don't think it'd be harmful to add the check, and it would make it a lot easier for wrapping drivers. I'll try taking a crack at it in CDRIVER-3748. |
kevinAlbs
left a comment
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.
Looking good, just some comments about handling NULL / freeing the server description.
src/mongocxx/private/index_view.hh
Outdated
| auto is_master = libmongoc::server_description_ismaster(server_description); | ||
|
|
||
| bson_iter_t iter; | ||
| bson_iter_init_find(&iter, is_master, "maxWireVersion"); |
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.
This could return false if the ismaster reply does not contain maxWireVersion. I don't think that would realistically happen (if there was no primary available, then mongoc_client_select_server would have returned NULL). But I think it is worth checking. If no maxWireVersion is available, throw an error.
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.
Done
src/mongocxx/test/index_view.cpp
Outdated
| Catch::Matches("(.*)commit( )?quorum(.*)", Catch::CaseSensitive::No); | ||
|
|
||
| using namespace test_util; | ||
| bool is_supported = compare_versions(get_server_version(mongodb_client), "4.4") >= 0 && |
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.
The test failure on s390x seems related to the version of MongoDB running.
say:
db version v4.3.0-2027-gbe045fe
That test is running against single, so is_supported would be false, and an exception is expected. But since that server version is likely reporting wire version 9, your wire version check is not getting hit. I think the right thing to do is change this comparison to check the wire version instead:
bool is_supported = get_max_wire_version (mongodb_client) >= 9 && get_topology (mongoc_client) != "single";
|
|
||
| class scoped_server_description { | ||
| public: | ||
| explicit scoped_server_description(mongoc_server_description_t* sd) : sd(sd) {} |
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.
Oh nice, I forgot about marking that explicit.
kevinAlbs
left a comment
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.
Changes LGTM. I still believe the failing zseries test is due to running against 4.3 and is not a bug in this implementation. I added a suggestion to resolve that.
| REQUIRE_THROWS_WITH(indexes.create_one(model, options), commit_quorum_regex); | ||
| } | ||
|
|
||
| SECTION("works with string") { |
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.
This section, and the section below, appear to be the ones failing.
As the capturing of is_supported shows, is_supported is false, an an exception is expected.
IIUC an exception is expected because the test runs against a single topology, but "majority" should only be supported on a replica set. And the section below expects a server to always reject the value "bad_str"
I still believe this is due to the intermediate 4.3.0 server version this is running against on zSeries. The server may have implemented validation after 4.3.0, so the reported wire version is still 9, but invalid commitQuorum values are still accepted. https://jira.mongodb.org/browse/SERVER-41846 in particular (which has fixVersion 4.3.1) seems related.
We could investigate further and check with the server team. But IMO, it is less important that we test server side validation of these values, and more important that we test that commitQuroum works when supported, and that the driver returns a client side error if the wire version is < 9.
I'd argue for removing the "fails with invalid string" test below, and only testing the "is_supported" case 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.
Per our discussion, I skipped single typologies and got rid of the invalid with... tests.
kevinAlbs
left a comment
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 with a warning log.
src/mongocxx/test/index_view.cpp
Outdated
| } | ||
|
|
||
| SECTION("commitQuorum option") { | ||
| if (test_util::get_topology(mongodb_client) == "single") |
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.
Can you add a warning for consistency with other skips? WARN("skip: commitQuorum option requires a replica set");
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.
Done.
No description provided.