Skip to content

Commit 6072b69

Browse files
authored
CDRIVER-4192 Support retryable handshake network errors (#1141)
* Move legacy retryable reads test files into legacy subdirectory * Move legacy retryable writes test files into legacy subdirectory * Sync unified retryable reads test files with 08230607 * Sync unified retryable writes test files with 08230607 * Sync unified transactions test files with 08230607 * Bump default task timeout from 40 minutes to to 1 hour * Address TSAN warnings in test_add_and_scan_failure * Address -Wunused-const-variable for gHexCharPairs * Improve error message when expected OP_MSG request is not received * Improve assertion message for monotonic clock time comparison * Address null pointer warnings by scan-build * CDRIVER-4517 Sync unified retryable writes tests files with b9cdbbbe * CDRIVER-4517 Sync unified retryable reads tests files with b9cdbbbe * Declare _mongoc_cluster_stream_for_server as static * Refactor _mongoc_bson_init_with_transient_txn_error -> _mongoc_add_transient_txn_error * Separate aggregates with writes from mongoc_cluster_stream_for_reads * Add _mongoc_error_is_auth * Declare _mongoc_write_error_append_retryable_label in mongoc-error-private.h * Remove always-true handshake_complete parameter from _handle_network_error * Assert preconditions for mongoc_cluster_stream_for_server * Permit empty arguments field for operation_list_collections * Retry when encountering a network error establishing an initial connection to a server * Update tests to account for retryable handshake network failures * Add unified test runner support for listDatabaseNames * Skip retryable reads tests that require unsupported optional helpers
1 parent 096f2e8 commit 6072b69

File tree

106 files changed

+5696
-465
lines changed

Some content is hidden

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

106 files changed

+5696
-465
lines changed

.evergreen/config.yml

Lines changed: 1 addition & 97 deletions
Large diffs are not rendered by default.

build/evergreen_config_lib/tasks.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -492,10 +492,8 @@ def __init__(self, *args, **kwargs):
492492
elif self.coverage:
493493
self.add_tags('test-coverage')
494494
self.add_tags(self.version)
495-
self.options['exec_timeout_secs'] = 3600
496495
elif self.sanitizer == "asan":
497496
self.add_tags('test-asan', self.version)
498-
self.options['exec_timeout_secs'] = 3600
499497
elif self.sanitizer == "tsan":
500498
self.add_tags('tsan')
501499
self.add_tags(self.version)
@@ -855,15 +853,13 @@ def __init__(self, *args, **kwargs):
855853
NamedTask(
856854
'test-coverage-latest-server-dns',
857855
tags=['test-coverage'],
858-
exec_timeout_secs=3600,
859856
commands=[func('debug-compile-coverage-notest-nosasl-openssl'),
860857
bootstrap(TOPOLOGY='replica_set', AUTH='auth', SSL='ssl'),
861858
run_tests(AUTH='auth', SSL='ssl', DNS='on'),
862859
func('update codecov.io')]),
863860
NamedTask(
864861
'authentication-tests-memcheck',
865862
tags=['authentication-tests', 'valgrind'],
866-
exec_timeout_seconds=3600,
867863
commands=[
868864
shell_mongoc("""
869865
VALGRIND=ON DEBUG=ON CC='${CC}' MARCH='${MARCH}' SASL=AUTO \
@@ -1120,7 +1116,6 @@ def __init__(self, *args, **kwargs):
11201116
"unimplemented configuration for LoadBalancedTask")
11211117

11221118
self.add_tags(self.version)
1123-
self.options['exec_timeout_secs'] = 3600
11241119

11251120
# Return the task name.
11261121
# Example: test-loadbalanced-asan-auth-openssl-latest

build/generate-evergreen-config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
config = OD([
5252
('stepback', True),
5353
('command_type', 'system'),
54-
# 40 minute max except valgrind tasks, which get 2 hours.
55-
('exec_timeout_secs', 2400),
54+
# 60 minute max except valgrind tasks, which get 2 hours.
55+
('exec_timeout_secs', 3600),
5656
('functions', all_functions),
5757
('pre', [
5858
OD([('func', 'fetch source')]),

src/libbson/src/bson/bson-oid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* to hex formatted ASCII. Performing two characters at a time roughly
3333
* reduces the number of operations by one-half.
3434
*/
35-
static const uint16_t gHexCharPairs[] = {
35+
BSON_MAYBE_UNUSED static const uint16_t gHexCharPairs[] = {
3636
#if BSON_BYTE_ORDER == BSON_BIG_ENDIAN
3737
12336, 12337, 12338, 12339, 12340, 12341, 12342, 12343, 12344, 12345, 12385,
3838
12386, 12387, 12388, 12389, 12390, 12592, 12593, 12594, 12595, 12596, 12597,

src/libmongoc/src/mongoc/mongoc-change-stream.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,8 @@ _make_cursor (mongoc_change_stream_t *stream)
294294
goto cleanup;
295295
}
296296

297-
server_stream =
298-
mongoc_cluster_stream_for_reads (&stream->client->cluster,
299-
stream->read_prefs,
300-
cs,
301-
&reply,
302-
/* Not aggregate-with-write */ false,
303-
&stream->err);
297+
server_stream = mongoc_cluster_stream_for_reads (
298+
&stream->client->cluster, stream->read_prefs, cs, &reply, &stream->err);
304299
if (!server_stream) {
305300
bson_destroy (&stream->err_doc);
306301
bson_copy_to (&reply, &stream->err_doc);

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,7 +1832,6 @@ _mongoc_client_retryable_read_command_with_stream (
18321832
parts->read_prefs,
18331833
parts->assembled.session,
18341834
NULL,
1835-
/* Not aggregate-with-write */ false,
18361835
&ignored_error);
18371836

18381837
if (retry_server_stream && retry_server_stream->sd->max_wire_version >=
@@ -1923,12 +1922,7 @@ mongoc_client_command_simple (mongoc_client_t *client,
19231922
* preference argument."
19241923
*/
19251924
server_stream =
1926-
mongoc_cluster_stream_for_reads (cluster,
1927-
read_prefs,
1928-
NULL,
1929-
reply,
1930-
/* Not aggregate-with-write */ false,
1931-
error);
1925+
mongoc_cluster_stream_for_reads (cluster, read_prefs, NULL, reply, error);
19321926

19331927
if (server_stream) {
19341928
ret = _mongoc_client_command_with_stream (
@@ -2088,12 +2082,7 @@ _mongoc_client_command_with_opts (mongoc_client_t *client,
20882082
mongoc_cluster_stream_for_writes (cluster, cs, reply_ptr, error);
20892083
} else {
20902084
server_stream =
2091-
mongoc_cluster_stream_for_reads (cluster,
2092-
prefs,
2093-
cs,
2094-
reply_ptr,
2095-
/* Not aggregate-with-write */ false,
2096-
error);
2085+
mongoc_cluster_stream_for_reads (cluster, prefs, cs, reply_ptr, error);
20972086
}
20982087

20992088
if (!server_stream) {

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ mongoc_cluster_stream_for_reads (mongoc_cluster_t *cluster,
123123
const mongoc_read_prefs_t *read_prefs,
124124
mongoc_client_session_t *cs,
125125
bson_t *reply,
126-
bool is_aggr_with_write,
127126
bson_error_t *error);
128127

129128
/**
@@ -143,6 +142,26 @@ mongoc_cluster_stream_for_writes (mongoc_cluster_t *cluster,
143142
bson_t *reply,
144143
bson_error_t *error);
145144

145+
/**
146+
* @brief Obtain a server stream appropriate for aggregate operations with
147+
* writes on the cluster.
148+
*
149+
* Returns a new stream (that must be freed) or NULL and sets an error via
150+
* `error`.
151+
*
152+
* @note The returned stream must be released via
153+
* `mongoc_server_stream_cleanup`.
154+
*
155+
* @note May add nodes and/or update the cluster's topology.
156+
*/
157+
mongoc_server_stream_t *
158+
mongoc_cluster_stream_for_aggr_with_write (
159+
mongoc_cluster_t *cluster,
160+
const mongoc_read_prefs_t *read_prefs,
161+
mongoc_client_session_t *cs,
162+
bson_t *reply,
163+
bson_error_t *error);
164+
146165
/**
147166
* @brief Obtain a server stream associated with the cluster node associated
148167
* with the given server ID.

0 commit comments

Comments
 (0)