[SERVER-53828] Fix unsequenced modifications in oplog_applier_impl_test.cpp Created: 15/Jan/21  Updated: 29/Oct/23  Resolved: 22/Jan/21

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

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

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Service Arch 2021-02-08
Participants:

 Description   

Building on XCode clang:
Apple clang version 12.0.0 (clang-1200.0.32.28)
Target: x86_64-apple-darwin20.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

oplog_applier_impl_test.cpp:1620:78: error: unsequenced modification and access to 'seconds' [-Werror,-Wunsequenced]

Occurs in 4 places.



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

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-53828 fix unsequenced operations in 2 tests
Branch: master
https://github.com/mongodb/mongo/commit/2124bf2d0f31bc21af6f3104a9025c2da8b9e14b

Comment by Billy Donahue [ 15/Jan/21 ]

CR https://mongodbcr.appspot.com/740880039

Comment by Billy Donahue [ 15/Jan/21 ]

I think changing the Duration constructor to take the count by value instead of by reference exposed this bug.

https://github.com/mongodb/mongo/blob/master/src/mongo/db/repl/oplog_applier_impl_test.cpp#L1620

There are a few places in the test that do this pattern:

    int seconds = 1;
    auto makeOp = [&seconds](const NamespaceString& nss) {
        return makeInsertDocumentOplogEntry(
            {Timestamp(Seconds(seconds), 0), 1LL}, nss, BSON("_id" << seconds++));
    };

And it's indeterminate whether Seconds(seconds) is executed before or after the seconds++.

PS: I'm also throwing in another XCode warning-made-error having to do with an unnecessary loop variable copy.
Doing both of these clears my build.

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