[SERVER-49321] Make VectorClock::Component protected Created: 07/Jul/20  Updated: 29/Oct/23  Resolved: 22/Jul/20

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 4.7.0

Type: Improvement Priority: Major - P3
Reporter: Kevin Pulo Assignee: Pierlauro Sciarelli
Resolution: Fixed Votes: 0
Labels: PM-1645-Milestone-3
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Participants:

 Description   

Instead provide an accessor for each Component in VectorTime. This will make external usage less clunky:

 auto now = VectorClock::get(opCtx)->getTime();
-auto clusterTime = now[VectorClock::Component::ClusterTime];
+auto clusterTime = now.clusterTime();

The accessors can also use an lvalue ref-qualifier to ensure that the current time is properly stored somewhere, ie. prevent the anti-pattern of:

auto clusterTime = VectorClock::get(opCtx)->getTime().clusterTime();
auto configTime = VectorClock::get(opCtx)->getTime().configTime();
// Cannot assume that configTime <= clusterTime.

which is potentially incorrect, relative to:

auto now = VectorClock::get(opCtx)->getTime();
auto clusterTime = now.clusterTime();
auto configTime = now.configTime();
// Must be true that configTime <= clusterTime.

The advanceTime_forTest will also need some consideration, likely by returning a temporary object that provides a mutator for each Component.



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

Author:

{'name': 'Pierlauro Sciarelli', 'email': 'pierlauro.sciarelli@mongodb.com', 'username': 'pierlauro'}

Message: SERVER-49321 Make VectorClock::Component protected
Branch: master
https://github.com/mongodb/mongo/commit/86d94765b9030c9aa9adb3899277456e64bbd348

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