[SERVER-62709] Fix `transport_layer_asio_test` build-failure on `Enterprise Windows C++20 DEBUG` Created: 18/Jan/22  Updated: 20/Nov/23  Resolved: 19/Jan/22

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 5.3.0

Type: Bug Priority: Major - P3
Reporter: Amirsaman Memaripour Assignee: Amirsaman Memaripour
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Related
related to SERVER-62763 Fix data-type used for passing option... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v5.0
Sprint: Service Arch 2022-1-24
Participants:
Linked BF Score: 70
Story Points: 1

 Description   

SERVER-62571 introduced a few changes to ThrowOnNetworkErrorInEnsureSync, one of the tests in transport_layer_asio_test.cpp, to fix a data-race in the unit-test. One of the changes was introducing a scope-guard, that will set a barrier upon returning from a lambda (defined here):

...
    unittest::Barrier barrier(2);
    ConnectionThread connectThread(tf.tla().listenerPort(), [&](ConnectionThread& conn) {
        ON_BLOCK_EXIT([&] { barrier.countDownAndWait(); }); // This line is causing the build failure.
 
        // Linger timeout = 0 causes a RST packet on close.
        struct linger sl = {1, 0};
        if (setsockopt(conn.socket().rawFD(),
                       SOL_SOCKET,
                       SO_LINGER,
                       reinterpret_cast<SetsockoptPtr>(&sl),
                       sizeof(sl)) != 0) {
            auto err = make_error_code(std::errc{errno});
            LOGV2_ERROR(6060300, "setsockopt", "error"_attr = err.message());
        }
    });
...

Building transport_layer_asio_test.cpp with "Enterprise Windows C++20 DEBUG" is failing after SERVER-62571 is merged. Removing the scope-guard, however, fixes the build-failure. This ticket should resolve the issue by either fixing the issue with scope-guards and the new Windows build system, or replacing the scope-guard with an alternative.



 Comments   
Comment by Githook User [ 19/Jan/22 ]

Author:

{'name': 'Amirsaman Memaripour', 'email': 'amirsaman.memaripour@mongodb.com', 'username': 'samanca'}

Message: SERVER-62709 Fix `transport_layer_asio_test` build failure
Branch: master
https://github.com/mongodb/mongo/commit/d8f3983e6976589cd9fa47c254cae015d9dbbd1a

Generated at Thu Feb 08 05:55:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.