[SERVER-69693] Use lambda instead of repeating code in resharding coordinator Created: 14/Sep/22  Updated: 29/Oct/23  Resolved: 14/Sep/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.0.13, 6.0.2, 6.1.0-rc3, 6.2.0-rc0

Type: Task Priority: Minor - P4
Reporter: Andrew Witten (Inactive) Assignee: Andrew Witten (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Backport Requested:
v6.1, v6.0, v5.0
Participants:

 Description   

In src/mongo/db/s/resharding/resharding_coordinator_commit_monitor.cpp we have code 

remainingTimes.max == Milliseconds::max() ? Milliseconds(-1) : remainingTimes.max 

and 

remainingTimes.min == Milliseconds::max() ? Milliseconds(-1) : remainingTimes.min 

Because repeating code like this is error prone (although not a bug), and to be consistent with branches 5.0 and 6.0, we should rewrite this to use a lambda

            auto returnIfNotMax = [](Milliseconds t) {
                return t != Milliseconds::max() ? t : Milliseconds(-1);
            }; 



 Comments   
Comment by Githook User [ 20/Sep/22 ]

Author:

{'name': 'Andrew Witten', 'email': 'andrew.witten@mongodb.com', 'username': 'awitten1'}

Message: SERVER-67653 don't initiate critical section if remainingMillis is omitted

(cherry picked from commit abd6330d793235c8fbc5de7bf3ec53855ebea9d3)

SERVER-69693 use lambda instead of repeating code

(cherry picked from commit dd9d37fa07a7af46ac4ee8dabeb235dc9571afb0)
Branch: v6.1
https://github.com/mongodb/mongo/commit/d5004b929a08ee46f9803b62a8f1239e3cc3f9bd

Comment by Githook User [ 14/Sep/22 ]

Author:

{'name': 'Andrew Witten', 'email': 'andrew.witten@mongodb.com', 'username': 'awitten1'}

Message: SERVER-67653 don't initiate critical section if remainingMillis is omitted

(cherry picked from commit abd6330d793235c8fbc5de7bf3ec53855ebea9d3)

SERVER-69693 Use lambda instead of repeating code in resharding coordinator
Branch: v6.0
https://github.com/mongodb/mongo/commit/1db7b70c4ff5fd88fd4922350c65b09805e19710

Comment by Githook User [ 14/Sep/22 ]

Author:

{'name': 'Andrew Witten', 'email': 'andrew.witten@mongodb.com', 'username': 'awitten1'}

Message: SERVER-67653 don't initiate critical section if remainingMillis is omitted

(cherry picked from commit abd6330d793235c8fbc5de7bf3ec53855ebea9d3)

SERVER-69693 Use lambda instead of repeating code in resharding coordinator
Branch: v5.0
https://github.com/mongodb/mongo/commit/2eebadf82faa58ac5aebc9e8238c7b299e316a7d

Comment by Githook User [ 14/Sep/22 ]

Author:

{'name': 'Andrew Witten', 'email': 'andrew.witten@mongodb.com', 'username': 'awitten1'}

Message: SERVER-69693 use lambda instead of repeating code
Branch: master
https://github.com/mongodb/mongo/commit/dd9d37fa07a7af46ac4ee8dabeb235dc9571afb0

Generated at Thu Feb 08 06:14:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.