title: MongoDB ReplicaSet - PRIMARY role falls to SECONDARY when only PRIMARY is left
body: <p>I am investigating using MongoDB ReplicaSet for high availability.</p>
  
  <p>But just discovered that in ReplicaSet with 3 nodes, if PRIMARY mongod is the only one left (that is 2 other <code>mongod</code> instances died or were shut down), then after several seconds it switches role to SECONDARY and accepts writes no more. That makes Replica Set worth less than single instance.</p>
  
  <p>I know &amp; understand about PRIMARY election, but the PRIMARY role is fixed to a server (by using <code>priority</code> set to ,say, 10) and (for example due to network problems) other servers become inaccessible, why the main server just gives up?!</p>
  
  <p>Tested with 2.4.8 on Windows (mongodb-win32-x86_64-2008plus-2.4.8) and Linux (CentOS) and 2.0.x on Linux</p>
  
  <p>BOUNTY STARTED:</p>
  
  <p>If the replica set gives up when PRIMARY feels alone, what are alternative to ensure 100% availability? Or maybe there is special configuration needed for the case. The current implementation makes ReplicaSet fragile in case of network problems.</p>
  
  <p>UPDATED:</p>
  
  <p>Alas, I have not said before the scenario when #3 goes down (PRIMARY &amp; SECONDARY are left)
  and then after a while SECONDARY goes down. Then PRIMARY really just "gives up", because it is already known that #3 is unavailable for some time.  This was actually tested in my test environment.</p>
  
  <pre><code>var rsconfig = {"_id":"rs4","members":[{"_id":0,"host":"localhost:27041","priority":10},{"_id":1,"host":"localhost:27042"},{"_id":2,"host":"localhost:27043","arbiterOnly":true}]}
  printjson(rsconfig)
  rs.initiate(rsconfig)
  </code></pre>
  
  <p>We initially thought to put SECONDARY and #3 (that is ARBITER) on the same server,
  but because of question in title, we cannot use such configuration.</p>
  
  <p>Thanks to  Alan Spencer for first explaining the logic that MongoDB takes.</p>