[SERVER-32233] NewPrimaryWithMaxElectionId test should ensure that electionId is newer every iteration Created: 08/Dec/17 Updated: 30/Oct/23 Resolved: 14/Feb/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 3.6.0 |
| Fix Version/s: | 3.7.3 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Randolph Tan | Assignee: | Randolph Tan |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | neweng | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||
| Issue Links: |
|
||||
| Backwards Compatibility: | Fully Compatible | ||||
| Operating System: | ALL | ||||
| Participants: | |||||
| Linked BF Score: | 0 | ||||
| Description |
|
Test should make sure that OID generated here is increasing for every iteration: https://github.com/mongodb/mongo/blob/r3.7.0/src/mongo/client/replica_set_monitor_test.cpp#L1013 |
| Comments |
| Comment by Githook User [ 14/Feb/18 ] |
|
Author: {'email': 'cramaechi@me.com', 'name': 'Chibuikem Amaechi', 'username': 'cramaechi'}Message: NewPrimaryWithMaxElectionId test should ensure that electionId is newer The problem is that the test assumes that OID generated per iteration is Use OID::fromTerm() in place of OID::gen(). Closes #1207 Signed-off-by: Randolph Tan <randolph@10gen.com> |
| Comment by Chibuikem Amaechi [ 24/Jan/18 ] |
|
Hi Randolph, Thanks for the clarification. In that case, I propose we use OID::fromTerm() in place of OID::gen() to ensure that electionId is increasing per iteration. As the integer value that is passed to OID::fromTerm() increases due to the for-loop, so does the underlying data of the OID object that is returned. |
| Comment by Randolph Tan [ 23/Jan/18 ] |
|
cramaechi Thanks for sharing. However, this does not fix the underlying issue. The problem is that the test assumes that OID generated per iteration is increasing. And this assumption is based on the fact that OID::gen constructs a value based on the return value from time(). However, there is no guarantee that time() will consistently be returning values that increases over time. |
| Comment by Chibuikem Amaechi [ 30/Dec/17 ] |
|
As mentioned above, there are currently no checks in place to ensure that a new electionId is generated for every iteration of the for-loop. My proposed change would be to declare an OID variable named nextOID and a string variable named prevOID outside the for-loop, and then maintain them inside the for-loop so that a less-than comparison between prevOID and nextOID.toString() can be passed to an ASSERT macro for processing. ex. src/mongo/client/replica_set_monitor_test.cpp Please share your thoughts. |