[SERVER-5110] ReplicaSetMonitor::check not thread safe wrt _master Created: 27/Feb/12  Updated: 11/Jul/16  Resolved: 03/Apr/12

Status: Closed
Project: Core Server
Component/s: Internal Client, Sharding
Affects Version/s: None
Fix Version/s: 2.0.5, 2.1.1

Type: Bug Priority: Major - P3
Reporter: Greg Studer Assignee: Randolph Tan
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-5302 Mongos Process Dying Signal 11 Closed
Duplicate
duplicates SERVER-5833 mongo crash Closed
duplicates SERVER-6245 Assertion Error: bsonobjbuilder.h:127 Closed
is duplicated by SERVER-5166 Removing replica set node can cause m... Closed
is duplicated by SERVER-7841 Segmentation faults and lost replicas... Closed
Related
related to SERVER-5362 ReplicaSetMonitor::notifySlaveFailure... Closed
related to SERVER-5392 Consider allowing only one thread to ... Closed
is related to SERVER-5496 Refactor ReplicaSetMonitor to avoid d... Closed
Operating System: ALL
Participants:

 Description   

It's possible for a thread to notifyFailure(), resetting the _master variable to -1, between the time when the _master variable is checked here and when it is actually used to access the nodes array. We need to acquire _lock to do this safely.

There may be other issues here - the _check code modifies _master without locks in other places?



 Comments   
Comment by auto [ 17/Apr/12 ]

Author:

{u'login': u'renctan', u'email': u'renctan@gmail.com', u'name': u'renctan'}

Message: undo SERVER-5110 chnages on log display logic
Branch: v2.0
https://github.com/mongodb/mongo/commit/7460b30455b080fcb957248784871aa66538cb1c

Comment by auto [ 17/Apr/12 ]

Author:

{u'login': u'', u'name': u'Randolph Tan', u'email': u'randolph@10gen.com'}

Message: SERVER-5110 ReplicaSetMonitor::check not thread safe wrt _master

Made chages to make sure that proper mutexes are held when modifying _master and _nodes.
Also made sure that index variables pointing to _nodes element still refers to what
it used to be after we re-acquire the mutex.
Branch: v2.0
https://github.com/mongodb/mongo/commit/aee93cd91ad5e25f6662ccfb26d89d1a1cd06e2b

Comment by auto [ 04/Apr/12 ]

Author:

{u'login': u'renctan', u'name': u'renctan', u'email': u'renctan@gmail.com'}

Message: undo SERVER-5110 chnages on log display logic
Branch: master
https://github.com/mongodb/mongo/commit/6980e9f942291028b6327a1565be26ebb072086f

Comment by auto [ 03/Apr/12 ]

Author:

{u'login': u'', u'name': u'Randolph Tan', u'email': u'randolph@10gen.com'}

Message: SERVER-5110 ReplicaSetMonitor::check not thread safe wrt _master

Made chages to make sure that proper mutexes are held when modifying _master and _nodes.
Also made sure that index variables pointing to _nodes element still refers to what
it used to be after we re-acquire the mutex.
Branch: master
https://github.com/mongodb/mongo/commit/ec1dfbd4d7baa79d1f74d6325383461d371142fe

Generated at Thu Feb 08 03:07:56 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.