Skip to content

CDRIVER-4629 Remove code requiring maxWireVersion less than WIRE_VERSION_OP_MSG #1248

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

Merged
merged 18 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
8b0b302
Sync deleted max-staleness tests (CDRIVER-4152, CDRIVER-4204)
eramongodb Apr 26, 2023
46d8bd8
Update /retryable_writes/failover to account for WIRE_VERSION_RETRYAB…
eramongodb Apr 26, 2023
5dae46d
Update /inheritance/aggregate to account for CDRIVER-3893
eramongodb Apr 27, 2023
24adc80
Remove references to WIRE_VERSION_FIND_CMD
eramongodb Apr 26, 2023
d8578c4
Remove references to WIRE_VERSION_KILLCURSORS_CMD
eramongodb Apr 26, 2023
b323906
Remove references to WIRE_VERSION_FAM_WRITE_CONCERN
eramongodb Apr 26, 2023
bbedfda
Remove references to WIRE_VERSION_READ_CONCERN
eramongodb Apr 26, 2023
f3febf8
Remove references to WIRE_VERSION_MAX_STALENESS
eramongodb Apr 26, 2023
a5a9e74
Remove references to WIRE_VERSION_CMD_WRITE_CONCERN
eramongodb Apr 26, 2023
5e558fa
Remove references to WIRE_VERSION_COLLATION
eramongodb Apr 26, 2023
e4bb6b4
Remove references to WIRE_VERSION_HINT_SERVER_SIDE_ERROR
eramongodb Apr 26, 2023
a717044
Remove references to WIRE_VERSION_ARRAY_FILTERS
eramongodb Apr 26, 2023
200babc
Remove references to WIRE_VERSION_RETRY_READS
eramongodb Apr 26, 2023
c2dc11b
Remove references to WIRE_VERSION_RETRY_WRITES
eramongodb Apr 26, 2023
e3b6101
Remove references to WIRE_VERSION_OP_MSG
eramongodb Apr 26, 2023
0210db2
Remove references to WIRE_VERSION_CHECKS (6) test framework functions
eramongodb Apr 27, 2023
868ffcb
Clean up mongo-write-command component interface
eramongodb Apr 27, 2023
6d06b57
Preserve CheckLive condition in /retryable_writes/legacy tests
eramongodb Apr 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/libmongoc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,6 @@ set (SOURCES ${SOURCES}
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-util.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-version-functions.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-write-command.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-write-command-legacy.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-write-concern.c
${PROJECT_SOURCE_DIR}/src/mongoc/service-gcp.c
${PROJECT_SOURCE_DIR}/../../src/common/common-b64.c
Expand Down
2 changes: 0 additions & 2 deletions src/libmongoc/src/mongoc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ set (src_libmongoc_src_mongoc_DIST_noinst_hs
mongoc-uri-private.h
mongoc-util-private.h
mongoc-write-command-private.h
mongoc-write-command-legacy-private.h
mongoc-write-concern-private.h
service-gcp.h
)
Expand Down Expand Up @@ -266,7 +265,6 @@ set (src_libmongoc_src_mongoc_DIST_cs
mongoc-util.c
mongoc-version-functions.c
mongoc-write-command.c
mongoc-write-command-legacy.c
mongoc-write-concern.c
mongoc-crypto.c
mongoc-scram.c
Expand Down
14 changes: 0 additions & 14 deletions src/libmongoc/src/mongoc/mongoc-aggregate.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,20 +313,6 @@ _mongoc_aggregate (mongoc_client_t *client,
GOTO (done);
}

if (aggregate_opts.write_concern_owned && has_write_key &&
server_stream->sd->max_wire_version < WIRE_VERSION_CMD_WRITE_CONCERN) {
bson_set_error (
&cursor->error,
MONGOC_ERROR_COMMAND,
MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION,
"\"aggregate\" with \"$out\" or \"$merge\" does not support "
"writeConcern with wire version %d, wire version %d is "
"required",
server_stream->sd->max_wire_version,
WIRE_VERSION_CMD_WRITE_CONCERN);
GOTO (done);
}

/* Only inherit WriteConcern when aggregate has $out or $merge */
if (!aggregate_opts.write_concern_owned && has_write_key) {
mongoc_write_concern_destroy (cursor->write_concern);
Expand Down
24 changes: 0 additions & 24 deletions src/libmongoc/src/mongoc/mongoc-client-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,30 +47,6 @@ BSON_BEGIN_DECLS
#define WIRE_VERSION_MIN 6 /* a.k.a. minWireVersion */
#define WIRE_VERSION_MAX 17 /* a.k.a. maxWireVersion */

/* first version that supported "find" and "getMore" commands */
#define WIRE_VERSION_FIND_CMD 4
/* first version with "killCursors" command */
#define WIRE_VERSION_KILLCURSORS_CMD 4
/* first version when findAndModify accepts writeConcern */
#define WIRE_VERSION_FAM_WRITE_CONCERN 4
/* first version to support readConcern */
#define WIRE_VERSION_READ_CONCERN 4
/* first version to support maxStalenessSeconds */
#define WIRE_VERSION_MAX_STALENESS 5
/* first version to support writeConcern */
#define WIRE_VERSION_CMD_WRITE_CONCERN 5
/* first version to support collation */
#define WIRE_VERSION_COLLATION 5
/* first version to support server-side errors for unsupported hint options */
#define WIRE_VERSION_HINT_SERVER_SIDE_ERROR 5
/* first version to support OP_MSG */
#define WIRE_VERSION_OP_MSG 6
/* first version to support array filters for "update" command */
#define WIRE_VERSION_ARRAY_FILTERS 6
/* first version to support retryable reads */
#define WIRE_VERSION_RETRY_READS 6
/* first version to support retryable writes */
#define WIRE_VERSION_RETRY_WRITES 6
/* version corresponding to server 4.0 release */
#define WIRE_VERSION_4_0 7
/* first version to support hint for "update" command */
Expand Down
41 changes: 7 additions & 34 deletions src/libmongoc/src/mongoc/mongoc-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1740,8 +1740,7 @@ _mongoc_client_retryable_write_command_with_stream (
retry_server_stream = mongoc_cluster_stream_for_writes (
&client->cluster, parts->assembled.session, NULL, &ignored_error);

if (retry_server_stream && retry_server_stream->sd->max_wire_version >=
WIRE_VERSION_RETRY_WRITES) {
if (retry_server_stream) {
parts->assembled.server_stream = retry_server_stream;
{
// Store the original error and reply before retry.
Expand Down Expand Up @@ -1834,8 +1833,7 @@ _mongoc_client_retryable_read_command_with_stream (
NULL,
&ignored_error);

if (retry_server_stream && retry_server_stream->sd->max_wire_version >=
WIRE_VERSION_RETRY_READS) {
if (retry_server_stream) {
parts->assembled.server_stream = retry_server_stream;
bson_destroy (reply);
GOTO (retry);
Expand Down Expand Up @@ -1990,8 +1988,6 @@ _mongoc_client_command_with_opts (mongoc_client_t *client,
mongoc_client_session_t *cs;
bson_t reply_local;
bson_t *reply_ptr;
int32_t wire_version;
int32_t wc_wire_version;
bool reply_initialized = false;
bool ret = false;

Expand Down Expand Up @@ -2091,45 +2087,23 @@ _mongoc_client_command_with_opts (mongoc_client_t *client,
GOTO (done);
}

wire_version = server_stream->sd->max_wire_version;
if (!mongoc_cmd_parts_append_read_write (
&parts, &read_write_opts, wire_version, error)) {
if (!mongoc_cmd_parts_append_read_write (&parts, &read_write_opts, error)) {
GOTO (done);
}

if (mode & MONGOC_CMD_WRITE) {
wc_wire_version = !strcasecmp (command_name, "findandmodify")
? WIRE_VERSION_FAM_WRITE_CONCERN
: WIRE_VERSION_CMD_WRITE_CONCERN;

if (read_write_opts.write_concern_owned &&
wire_version < wc_wire_version) {
bson_set_error (error,
MONGOC_ERROR_COMMAND,
MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION,
"\"%s\" command does not support writeConcern with "
"wire version %d, wire version %d is required",
command_name,
wire_version,
wc_wire_version);
GOTO (done);
}

/* use default write concern unless it's in opts */
if (!mongoc_write_concern_is_default (default_wc) &&
!read_write_opts.write_concern_owned &&
wire_version >= wc_wire_version) {
if (!mongoc_cmd_parts_set_write_concern (
&parts, default_wc, wire_version, error)) {
!read_write_opts.write_concern_owned) {
if (!mongoc_cmd_parts_set_write_concern (&parts, default_wc, error)) {
GOTO (done);
}
}
}

/* use default read concern for read command, unless it's in opts */
if ((mode & MONGOC_CMD_READ) && bson_empty (&read_write_opts.readConcern)) {
if (!mongoc_cmd_parts_set_read_concern (
&parts, default_rc, wire_version, error)) {
if (!mongoc_cmd_parts_set_read_concern (&parts, default_rc, error)) {
GOTO (done);
}
}
Expand Down Expand Up @@ -2342,8 +2316,7 @@ _mongoc_client_kill_cursor (mongoc_client_t *client,
return;
}

if (db && collection &&
server_stream->sd->max_wire_version >= WIRE_VERSION_KILLCURSORS_CMD) {
if (db && collection) {
_mongoc_client_killcursors_command (
&client->cluster, server_stream, cursor_id, db, collection, cs);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/libmongoc/src/mongoc/mongoc-cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ mongoc_cluster_run_command_monitored (mongoc_cluster_t *cluster,
}

if (mongoc_cluster_uses_server_api (cluster) ||
server_stream->sd->max_wire_version >= WIRE_VERSION_OP_MSG) {
server_stream->sd->max_wire_version >= WIRE_VERSION_MIN) {
retval = mongoc_cluster_run_opmsg (cluster, cmd, reply, error);
} else {
retval = mongoc_cluster_run_command_opquery (
Expand Down Expand Up @@ -685,7 +685,7 @@ mongoc_cluster_run_command_private (mongoc_cluster_t *cluster,
server_stream = cmd->server_stream;

if (mongoc_cluster_uses_server_api (cluster) ||
server_stream->sd->max_wire_version >= WIRE_VERSION_OP_MSG) {
server_stream->sd->max_wire_version >= WIRE_VERSION_MIN) {
retval = mongoc_cluster_run_opmsg (cluster, cmd, reply, error);
} else {
retval =
Expand Down
4 changes: 0 additions & 4 deletions src/libmongoc/src/mongoc/mongoc-cmd-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,25 +107,21 @@ mongoc_cmd_parts_set_server_api (mongoc_cmd_parts_t *parts,
bool
mongoc_cmd_parts_append_opts (mongoc_cmd_parts_t *parts,
bson_iter_t *iter,
int max_wire_version,
bson_error_t *error);

bool
mongoc_cmd_parts_set_read_concern (mongoc_cmd_parts_t *parts,
const mongoc_read_concern_t *rc,
int max_wire_version,
bson_error_t *error);

bool
mongoc_cmd_parts_set_write_concern (mongoc_cmd_parts_t *parts,
const mongoc_write_concern_t *wc,
int max_wire_version,
bson_error_t *error);

bool
mongoc_cmd_parts_append_read_write (mongoc_cmd_parts_t *parts,
mongoc_read_write_opts_t *rw_opts,
int max_wire_version,
bson_error_t *error);

bool
Expand Down
Loading