majority_commit.txt 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. # The empty quorum commits "everything". This is useful for its use in joint
  2. # quorums.
  3. committed
  4. ----
  5. <empty majority quorum>∞
  6. # A single voter quorum is not final when no index is known.
  7. committed cfg=(1) idx=(_)
  8. ----
  9. idx
  10. ? 0 (id=1)
  11. 0
  12. # When an index is known, that's the committed index, and that's final.
  13. committed cfg=(1) idx=(12)
  14. ----
  15. idx
  16. > 12 (id=1)
  17. 12
  18. # With two nodes, start out similarly.
  19. committed cfg=(1, 2) idx=(_,_)
  20. ----
  21. idx
  22. ? 0 (id=1)
  23. ? 0 (id=2)
  24. 0
  25. # The first committed index becomes known (for n1). Nothing changes in the
  26. # output because idx=12 is not known to be on a quorum (which is both nodes).
  27. committed cfg=(1, 2) idx=(12,_)
  28. ----
  29. idx
  30. x> 12 (id=1)
  31. ? 0 (id=2)
  32. 0
  33. # The second index comes in and finalize the decision. The result will be the
  34. # smaller of the two indexes.
  35. committed cfg=(1,2) idx=(12,5)
  36. ----
  37. idx
  38. x> 12 (id=1)
  39. > 5 (id=2)
  40. 5
  41. # No surprises for three nodes.
  42. committed cfg=(1,2,3) idx=(_,_,_)
  43. ----
  44. idx
  45. ? 0 (id=1)
  46. ? 0 (id=2)
  47. ? 0 (id=3)
  48. 0
  49. committed cfg=(1,2,3) idx=(12,_,_)
  50. ----
  51. idx
  52. xx> 12 (id=1)
  53. ? 0 (id=2)
  54. ? 0 (id=3)
  55. 0
  56. # We see a committed index, but a higher committed index for the last pending
  57. # votes could change (increment) the outcome, so not final yet.
  58. committed cfg=(1,2,3) idx=(12,5,_)
  59. ----
  60. idx
  61. xx> 12 (id=1)
  62. x> 5 (id=2)
  63. ? 0 (id=3)
  64. 5
  65. # a) the case in which it does:
  66. committed cfg=(1,2,3) idx=(12,5,6)
  67. ----
  68. idx
  69. xx> 12 (id=1)
  70. > 5 (id=2)
  71. x> 6 (id=3)
  72. 6
  73. # b) the case in which it does not:
  74. committed cfg=(1,2,3) idx=(12,5,4)
  75. ----
  76. idx
  77. xx> 12 (id=1)
  78. x> 5 (id=2)
  79. > 4 (id=3)
  80. 5
  81. # c) a different case in which the last index is pending but it has no chance of
  82. # swaying the outcome (because nobody in the current quorum agrees on anything
  83. # higher than the candidate):
  84. committed cfg=(1,2,3) idx=(5,5,_)
  85. ----
  86. idx
  87. x> 5 (id=1)
  88. > 5 (id=2)
  89. ? 0 (id=3)
  90. 5
  91. # c) continued: Doesn't matter what shows up last. The result is final.
  92. committed cfg=(1,2,3) idx=(5,5,12)
  93. ----
  94. idx
  95. > 5 (id=1)
  96. > 5 (id=2)
  97. xx> 12 (id=3)
  98. 5
  99. # With all committed idx known, the result is final.
  100. committed cfg=(1, 2, 3) idx=(100, 101, 103)
  101. ----
  102. idx
  103. > 100 (id=1)
  104. x> 101 (id=2)
  105. xx> 103 (id=3)
  106. 101
  107. # Some more complicated examples. Similar to case c) above. The result is
  108. # already final because no index higher than 103 is one short of quorum.
  109. committed cfg=(1, 2, 3, 4, 5) idx=(101, 104, 103, 103,_)
  110. ----
  111. idx
  112. x> 101 (id=1)
  113. xxxx> 104 (id=2)
  114. xx> 103 (id=3)
  115. > 103 (id=4)
  116. ? 0 (id=5)
  117. 103
  118. # A similar case which is not final because another vote for >= 103 would change
  119. # the outcome.
  120. committed cfg=(1, 2, 3, 4, 5) idx=(101, 102, 103, 103,_)
  121. ----
  122. idx
  123. x> 101 (id=1)
  124. xx> 102 (id=2)
  125. xxx> 103 (id=3)
  126. > 103 (id=4)
  127. ? 0 (id=5)
  128. 102