[SERVER-42994] Minimize and move tryToGoLiveAsASecondary Created: 23/Aug/19  Updated: 29/Oct/23  Resolved: 13/Sep/19

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: None
Fix Version/s: 4.3.1

Type: Improvement Priority: Major - P3
Reporter: A. Jesse Jiryu Davis Assignee: A. Jesse Jiryu Davis
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Repl 2019-08-26, Repl 2019-09-09, Repl 2019-09-23
Participants:

 Description   

This free function in sync_tail.cpp is called several layers deep in the oplog application code. It is called before applying each batch, and it attempts to transition the member state to SECONDARY by calling several ReplicationCoordinator methods. I think the member state is typically RECOVERING or SECONDARY when this function is called.

Judah theorizes that this function is practically obsolete and is typically a no-op, except in enableMajorityReadConcern false mode, where we do rollback via refetch. (Note from Jesse: yes this seems to be true. There's also forceRollbackViaRefetch but it can be removed, SERVER-41931.)

Changing member state should be the responsibility of the ReplicationCoordinator, not SyncTail. Remove obsolete code from tryToGoLiveAsASecondary(), then convert it to a method in the ReplicationCoordinator. If possible, reverse control: the ReplicationCoordinator should trigger changes in oplog application after it decides to become a secondary, not vice-versa. However, it may not be possible: ReplicationCoordinator needs the applier to signal it when it is the right time to transition its state, just like signalDrainComplete, where we transition to Primary. If it's not possible to reverse control this way, then at least the code will be moved to the right class.



 Comments   
Comment by Githook User [ 12/Sep/19 ]

Author:

{'username': 'ajdavis', 'email': 'jesse@mongodb.com', 'name': 'A. Jesse Jiryu Davis'}

Message: SERVER-42994 Add finishRecoveryIfEligible to ReplCoordinator

This logic was in a free function tryToGoLiveAsASecondary in sync_tail.cpp, but belongs with other
state-change methods on ReplicationCoordinator.
Branch: master
https://github.com/mongodb/mongo/commit/6922691bee2575455d666b5d6d13ff73fc315c53

Comment by Githook User [ 12/Sep/19 ]

Author:

{'username': 'ajdavis', 'email': 'jesse@mongodb.com', 'name': 'A. Jesse Jiryu Davis'}

Message: SERVER-42994 Add finishRecoveryIfEligible to ReplCoordinatorNoOp
Branch: master
https://github.com/10gen/mongo-enterprise-modules/commit/80f1ab4a271fc09e903d5bfe2e70b878c1729711

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