-
Notifications
You must be signed in to change notification settings - Fork 456
CDRIVER-6080 track client streams in connection counting tests #2095
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
base: master
Are you sure you want to change the base?
Conversation
Update tests checking server-side connections. Intended to fix flaky failures.
To fix IPv4/IPv6 tests that use IP literals
Accidentally removed during rebase
bson_t *cmd = BCON_NEW("serverStatus", BCON_INT32(1)); | ||
bson_t reply; | ||
bson_error_t error; | ||
bool ok = mongoc_client_command_simple(client, "admin", cmd, NULL, &reply, &error); | ||
if (!ok) { | ||
printf("serverStatus failed: %s\n", error.message); | ||
abort(); | ||
} | ||
int32_t conns; | ||
// Get `connections.current` from the reply. | ||
{ | ||
bson_iter_t iter; | ||
BSON_ASSERT(bson_iter_init_find(&iter, &reply, "connections")); | ||
BSON_ASSERT(bson_iter_recurse(&iter, &iter)); | ||
BSON_ASSERT(bson_iter_find(&iter, "current")); | ||
conns = bson_iter_int32(&iter); | ||
} |
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.
There is a similar function which uses connections.totalCreated
. Should this also be updated to use the new stream tracker?
src/libmongoc/tests/stream-tracker.h
Outdated
void | ||
stream_tracker_track_pool(stream_tracker_t *st, mongoc_client_pool_t *pool); | ||
|
||
unsigned |
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.
unsigned | |
int |
Avoid unsigned integers for counting. (CppCoreGuidelines)
src/libmongoc/tests/stream-tracker.c
Outdated
} | ||
|
||
|
||
mongoc_stream_t * |
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.
mongoc_stream_t * | |
static mongoc_stream_t * |
Internal linkage.
src/libmongoc/tests/stream-tracker.h
Outdated
expect, \ | ||
_got); \ | ||
} \ | ||
mlib_sleep_for(10, ms); \ |
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.
10ms is pretty short given a 5 seconds timeout. Perhaps use 100ms or 1s instead?
src/libmongoc/tests/stream-tracker.c
Outdated
|
||
typedef struct { | ||
mongoc_host_list_t host; | ||
unsigned count; |
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.
unsigned count; | |
int count; |
Avoid unsigned integers for counting. (CppCoreGuidelines)
stream_tracker_assert_count(st, "localhost.test.build.10gen.cc:27017", 0u); | ||
stream_tracker_assert_count(st, "localhost.test.build.10gen.cc:27018", 0u); |
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.
stream_tracker_assert_count(st, "localhost.test.build.10gen.cc:27017", 0u); | |
stream_tracker_assert_count(st, "localhost.test.build.10gen.cc:27018", 0u); | |
stream_tracker_assert_count(st, host0, 0u); | |
stream_tracker_assert_count(st, host1, 0u); |
These hostnames should be made variables due to repeated reuse.
stream_tracker_assert_count(st, "localhost:27017", 0u); | ||
stream_tracker_assert_count(st, "localhost:27018", 0u); |
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.
stream_tracker_assert_count(st, "localhost:27017", 0u); | |
stream_tracker_assert_count(st, "localhost:27018", 0u); | |
stream_tracker_assert_count(st, host0, 0u); | |
stream_tracker_assert_count(st, host1, 0u); |
These hostnames should be made variables due to repeated reuse.
Co-authored-by: Ezra Chung <[email protected]>
Previously checking a connection count (by running `serverStatus`) could trigger creating a new connection.
Summary
This PR adds a test utility to count client-side streams:
stream_tracker_t
.Tests in CDRIVER-6080 are unskipped and updated to replace server-side connection tracking with the client-side stream tracking.
As a drive-by fix, the
llvm-symbolizer
path is updated to prefer/opt/mongodbtoolchain/v4
if available.Motivation
Running only
/client_pool/disconnects_removed_servers/on_push
on 100x-repeat reproduced failures: https://spruce.mongodb.com/version/689f2acc28a3590007ece216:With fixes from this PR, the test consistently appears to pass: https://spruce.mongodb.com/version/68a1fc25c3e9fc00072bbb70.
The test previously used the server-reported
connections.current
fromserverStatus
. Quoting docs:I suspect
connections.current
might fluctuate from internal connections or (possibly) other connecting host processes. Testing locally, I sawconnections.current
increase after adding a replica set member, then later decrease after some time passed. And I am unsure if other processes on a host might be connecting.llvm-symbolizer path
Updating the
llvm-symbolizer
path was motivated by an observed failure to report a leak: https://spruce.mongodb.com/version/68a0851cae97e00007709c1a:After updated llvm-symbolizer path: https://spruce.mongodb.com/version/68a1fb780780030007cac342: