Skip to content

Commit 46e65b5

Browse files
authored
CDRIVER-4629 Remove code requiring maxWireVersion less than WIRE_VERSION_OP_MSG (#1248)
* Sync deleted max-staleness tests (CDRIVER-4152, CDRIVER-4204) * Update /retryable_writes/failover to account for WIRE_VERSION_RETRYABLE_WRITE_ERROR_LABEL * Update /inheritance/aggregate to account for CDRIVER-3893 * Remove references to WIRE_VERSION_FIND_CMD * Remove references to WIRE_VERSION_KILLCURSORS_CMD * Remove references to WIRE_VERSION_FAM_WRITE_CONCERN * Remove references to WIRE_VERSION_READ_CONCERN * Remove references to WIRE_VERSION_MAX_STALENESS * Remove references to WIRE_VERSION_CMD_WRITE_CONCERN * Remove references to WIRE_VERSION_COLLATION * Remove references to WIRE_VERSION_HINT_SERVER_SIDE_ERROR * Remove references to WIRE_VERSION_ARRAY_FILTERS * Remove references to WIRE_VERSION_RETRY_READS * Remove references to WIRE_VERSION_RETRY_WRITES * Remove references to WIRE_VERSION_OP_MSG * Remove references to WIRE_VERSION_CHECKS (6) test framework functions
1 parent b33adad commit 46e65b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+330
-1743
lines changed

src/libmongoc/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,6 @@ set (SOURCES ${SOURCES}
581581
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-util.c
582582
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-version-functions.c
583583
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-write-command.c
584-
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-write-command-legacy.c
585584
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-write-concern.c
586585
${PROJECT_SOURCE_DIR}/src/mongoc/service-gcp.c
587586
${PROJECT_SOURCE_DIR}/../../src/common/common-b64.c

src/libmongoc/src/mongoc/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ set (src_libmongoc_src_mongoc_DIST_noinst_hs
176176
mongoc-uri-private.h
177177
mongoc-util-private.h
178178
mongoc-write-command-private.h
179-
mongoc-write-command-legacy-private.h
180179
mongoc-write-concern-private.h
181180
service-gcp.h
182181
)
@@ -266,7 +265,6 @@ set (src_libmongoc_src_mongoc_DIST_cs
266265
mongoc-util.c
267266
mongoc-version-functions.c
268267
mongoc-write-command.c
269-
mongoc-write-command-legacy.c
270268
mongoc-write-concern.c
271269
mongoc-crypto.c
272270
mongoc-scram.c

src/libmongoc/src/mongoc/mongoc-aggregate.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -313,20 +313,6 @@ _mongoc_aggregate (mongoc_client_t *client,
313313
GOTO (done);
314314
}
315315

316-
if (aggregate_opts.write_concern_owned && has_write_key &&
317-
server_stream->sd->max_wire_version < WIRE_VERSION_CMD_WRITE_CONCERN) {
318-
bson_set_error (
319-
&cursor->error,
320-
MONGOC_ERROR_COMMAND,
321-
MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION,
322-
"\"aggregate\" with \"$out\" or \"$merge\" does not support "
323-
"writeConcern with wire version %d, wire version %d is "
324-
"required",
325-
server_stream->sd->max_wire_version,
326-
WIRE_VERSION_CMD_WRITE_CONCERN);
327-
GOTO (done);
328-
}
329-
330316
/* Only inherit WriteConcern when aggregate has $out or $merge */
331317
if (!aggregate_opts.write_concern_owned && has_write_key) {
332318
mongoc_write_concern_destroy (cursor->write_concern);

src/libmongoc/src/mongoc/mongoc-client-private.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -47,30 +47,6 @@ BSON_BEGIN_DECLS
4747
#define WIRE_VERSION_MIN 6 /* a.k.a. minWireVersion */
4848
#define WIRE_VERSION_MAX 17 /* a.k.a. maxWireVersion */
4949

50-
/* first version that supported "find" and "getMore" commands */
51-
#define WIRE_VERSION_FIND_CMD 4
52-
/* first version with "killCursors" command */
53-
#define WIRE_VERSION_KILLCURSORS_CMD 4
54-
/* first version when findAndModify accepts writeConcern */
55-
#define WIRE_VERSION_FAM_WRITE_CONCERN 4
56-
/* first version to support readConcern */
57-
#define WIRE_VERSION_READ_CONCERN 4
58-
/* first version to support maxStalenessSeconds */
59-
#define WIRE_VERSION_MAX_STALENESS 5
60-
/* first version to support writeConcern */
61-
#define WIRE_VERSION_CMD_WRITE_CONCERN 5
62-
/* first version to support collation */
63-
#define WIRE_VERSION_COLLATION 5
64-
/* first version to support server-side errors for unsupported hint options */
65-
#define WIRE_VERSION_HINT_SERVER_SIDE_ERROR 5
66-
/* first version to support OP_MSG */
67-
#define WIRE_VERSION_OP_MSG 6
68-
/* first version to support array filters for "update" command */
69-
#define WIRE_VERSION_ARRAY_FILTERS 6
70-
/* first version to support retryable reads */
71-
#define WIRE_VERSION_RETRY_READS 6
72-
/* first version to support retryable writes */
73-
#define WIRE_VERSION_RETRY_WRITES 6
7450
/* version corresponding to server 4.0 release */
7551
#define WIRE_VERSION_4_0 7
7652
/* first version to support hint for "update" command */

src/libmongoc/src/mongoc/mongoc-client.c

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,8 +1740,7 @@ _mongoc_client_retryable_write_command_with_stream (
17401740
retry_server_stream = mongoc_cluster_stream_for_writes (
17411741
&client->cluster, parts->assembled.session, NULL, &ignored_error);
17421742

1743-
if (retry_server_stream && retry_server_stream->sd->max_wire_version >=
1744-
WIRE_VERSION_RETRY_WRITES) {
1743+
if (retry_server_stream) {
17451744
parts->assembled.server_stream = retry_server_stream;
17461745
{
17471746
// Store the original error and reply before retry.
@@ -1834,8 +1833,7 @@ _mongoc_client_retryable_read_command_with_stream (
18341833
NULL,
18351834
&ignored_error);
18361835

1837-
if (retry_server_stream && retry_server_stream->sd->max_wire_version >=
1838-
WIRE_VERSION_RETRY_READS) {
1836+
if (retry_server_stream) {
18391837
parts->assembled.server_stream = retry_server_stream;
18401838
bson_destroy (reply);
18411839
GOTO (retry);
@@ -1990,8 +1988,6 @@ _mongoc_client_command_with_opts (mongoc_client_t *client,
19901988
mongoc_client_session_t *cs;
19911989
bson_t reply_local;
19921990
bson_t *reply_ptr;
1993-
int32_t wire_version;
1994-
int32_t wc_wire_version;
19951991
bool reply_initialized = false;
19961992
bool ret = false;
19971993

@@ -2091,45 +2087,23 @@ _mongoc_client_command_with_opts (mongoc_client_t *client,
20912087
GOTO (done);
20922088
}
20932089

2094-
wire_version = server_stream->sd->max_wire_version;
2095-
if (!mongoc_cmd_parts_append_read_write (
2096-
&parts, &read_write_opts, wire_version, error)) {
2090+
if (!mongoc_cmd_parts_append_read_write (&parts, &read_write_opts, error)) {
20972091
GOTO (done);
20982092
}
20992093

21002094
if (mode & MONGOC_CMD_WRITE) {
2101-
wc_wire_version = !strcasecmp (command_name, "findandmodify")
2102-
? WIRE_VERSION_FAM_WRITE_CONCERN
2103-
: WIRE_VERSION_CMD_WRITE_CONCERN;
2104-
2105-
if (read_write_opts.write_concern_owned &&
2106-
wire_version < wc_wire_version) {
2107-
bson_set_error (error,
2108-
MONGOC_ERROR_COMMAND,
2109-
MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION,
2110-
"\"%s\" command does not support writeConcern with "
2111-
"wire version %d, wire version %d is required",
2112-
command_name,
2113-
wire_version,
2114-
wc_wire_version);
2115-
GOTO (done);
2116-
}
2117-
21182095
/* use default write concern unless it's in opts */
21192096
if (!mongoc_write_concern_is_default (default_wc) &&
2120-
!read_write_opts.write_concern_owned &&
2121-
wire_version >= wc_wire_version) {
2122-
if (!mongoc_cmd_parts_set_write_concern (
2123-
&parts, default_wc, wire_version, error)) {
2097+
!read_write_opts.write_concern_owned) {
2098+
if (!mongoc_cmd_parts_set_write_concern (&parts, default_wc, error)) {
21242099
GOTO (done);
21252100
}
21262101
}
21272102
}
21282103

21292104
/* use default read concern for read command, unless it's in opts */
21302105
if ((mode & MONGOC_CMD_READ) && bson_empty (&read_write_opts.readConcern)) {
2131-
if (!mongoc_cmd_parts_set_read_concern (
2132-
&parts, default_rc, wire_version, error)) {
2106+
if (!mongoc_cmd_parts_set_read_concern (&parts, default_rc, error)) {
21332107
GOTO (done);
21342108
}
21352109
}
@@ -2342,8 +2316,7 @@ _mongoc_client_kill_cursor (mongoc_client_t *client,
23422316
return;
23432317
}
23442318

2345-
if (db && collection &&
2346-
server_stream->sd->max_wire_version >= WIRE_VERSION_KILLCURSORS_CMD) {
2319+
if (db && collection) {
23472320
_mongoc_client_killcursors_command (
23482321
&client->cluster, server_stream, cursor_id, db, collection, cs);
23492322
} else {

src/libmongoc/src/mongoc/mongoc-cluster.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ mongoc_cluster_run_command_monitored (mongoc_cluster_t *cluster,
546546
}
547547

548548
if (mongoc_cluster_uses_server_api (cluster) ||
549-
server_stream->sd->max_wire_version >= WIRE_VERSION_OP_MSG) {
549+
server_stream->sd->max_wire_version >= WIRE_VERSION_MIN) {
550550
retval = mongoc_cluster_run_opmsg (cluster, cmd, reply, error);
551551
} else {
552552
retval = mongoc_cluster_run_command_opquery (
@@ -685,7 +685,7 @@ mongoc_cluster_run_command_private (mongoc_cluster_t *cluster,
685685
server_stream = cmd->server_stream;
686686

687687
if (mongoc_cluster_uses_server_api (cluster) ||
688-
server_stream->sd->max_wire_version >= WIRE_VERSION_OP_MSG) {
688+
server_stream->sd->max_wire_version >= WIRE_VERSION_MIN) {
689689
retval = mongoc_cluster_run_opmsg (cluster, cmd, reply, error);
690690
} else {
691691
retval =

src/libmongoc/src/mongoc/mongoc-cmd-private.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,25 +107,21 @@ mongoc_cmd_parts_set_server_api (mongoc_cmd_parts_t *parts,
107107
bool
108108
mongoc_cmd_parts_append_opts (mongoc_cmd_parts_t *parts,
109109
bson_iter_t *iter,
110-
int max_wire_version,
111110
bson_error_t *error);
112111

113112
bool
114113
mongoc_cmd_parts_set_read_concern (mongoc_cmd_parts_t *parts,
115114
const mongoc_read_concern_t *rc,
116-
int max_wire_version,
117115
bson_error_t *error);
118116

119117
bool
120118
mongoc_cmd_parts_set_write_concern (mongoc_cmd_parts_t *parts,
121119
const mongoc_write_concern_t *wc,
122-
int max_wire_version,
123120
bson_error_t *error);
124121

125122
bool
126123
mongoc_cmd_parts_append_read_write (mongoc_cmd_parts_t *parts,
127124
mongoc_read_write_opts_t *rw_opts,
128-
int max_wire_version,
129125
bson_error_t *error);
130126

131127
bool

0 commit comments

Comments
 (0)