Skip to content

Conversation

kevinAlbs
Copy link
Collaborator

Summary

Do not set write concern timeout in most tests executing server operations.

Background & Motivation

Intended to fix recent observed failures in Evergreen. Example:

FAIL:/Users/ec2-user/data/mci/ffb7ebf283ddea39b3d6257ed6eff9b4/mongoc/src/libmongoc/tests/test-mongoc-client-side-encryption.c:76  _before_test()
  ret
  waiting for replication timed out; Error details: { wtimeout: true, writeConcern: { w: "majority", wtimeout: 1000, provenance: "clientSupplied" } } at sh01

I expect the 1 second timeout is sometimes too short (IIRC servers on macOS Evergreen hosts generally run slower).

Removing wTimeout is expected to mean "no timeout". Quoting docs:

If you do not specify the wtimeout option and the level of write concern is unachievable, the write operation will block indefinitely. Specifying a wtimeout value of 0 is equivalent to a write concern without the wtimeout option.

Exceptions:

  • Two tests in test-mongoc-sample-commands.c keep their wTimeout. These are used as documentation examples and intended to match the descriptions of DRIVERS-547 and DRIVERS-655.
  • Files in src/libmongoc/examples are left as-is. The examples are not run in Evergreen.

References:

Intended to resolve observed "waiting for replication timed out" test failures
Use wTimeout=1000 to match DRIVERS-655.
@kevinAlbs kevinAlbs requested a review from a team as a code owner September 26, 2025 19:00
@eramongodb
Copy link
Contributor

Should these also be updated?

/* mongoc_write_concern_set_wmajority() only assigns wtimeout if
* it is >= 0. Since we set wtimeout below, pass -1 here. */
mongoc_write_concern_set_wmajority(write_concern, -1);

mongoc_write_concern_set_wmajority(write_concern, 1000);

@kevinAlbs
Copy link
Collaborator Author

kevinAlbs commented Sep 29, 2025

Should these also be updated?

/* mongoc_write_concern_set_wmajority() only assigns wtimeout if
* it is >= 0. Since we set wtimeout below, pass -1 here. */
mongoc_write_concern_set_wmajority(write_concern, -1);

Updated to use mongoc_write_concern_set_w(write_concern, MONGOC_WRITE_CONCERN_W_MAJORITY); to simplify. No behavior change is expected, but it removes the unused -1 timeout.

Removed another instance of an unnecessary 0 timeout in client-side-encryption-server-schema.c

mongoc_write_concern_set_wmajority(write_concern, 1000);

Kept as-is since the test later checks the timeout is 1000.

@kevinAlbs kevinAlbs merged commit e5c3235 into mongodb:master Oct 1, 2025
44 of 46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants