@@ -146,9 +146,10 @@ fn quorum_compute(
146
146
. any ( |( _, details) | details. member . shrink_only ) ;
147
147
148
148
let metadata = format ! (
149
- "[{}/{} participants healthy][shrink_only={}]" ,
149
+ "[{}/{} participants healthy][{} heartbeating][ shrink_only={}]" ,
150
150
healthy_participants. len( ) ,
151
151
state. participants. len( ) ,
152
+ healthy_replicas. len( ) ,
152
153
shrink_only,
153
154
) ;
154
155
@@ -190,7 +191,7 @@ fn quorum_compute(
190
191
return (
191
192
None ,
192
193
format ! (
193
- "No quorum, only have {} participants, need min_replicas {} {}" ,
194
+ "New quorum not ready , only have {} participants, need min_replicas {} {}" ,
194
195
healthy_participants. len( ) ,
195
196
opt. min_replicas,
196
197
metadata
@@ -203,7 +204,7 @@ fn quorum_compute(
203
204
return (
204
205
None ,
205
206
format ! (
206
- "No quorum, only have {} participants, need at least half of {} healthy workers {}" ,
207
+ "New quorum not ready , only have {} participants, need at least half of {} healthy workers {}" ,
207
208
healthy_participants. len( ) ,
208
209
healthy_replicas. len( ) ,
209
210
metadata
@@ -261,7 +262,7 @@ impl Lighthouse {
261
262
262
263
fn _quorum_tick ( self : Arc < Self > , state : & mut State ) -> Result < ( ) > {
263
264
let ( quorum_met, reason) = quorum_compute ( Instant :: now ( ) , state, & self . opt ) ;
264
- info ! ( "{}" , reason) ;
265
+ info ! ( "Next quorum status: {}" , reason) ;
265
266
266
267
if quorum_met. is_some ( ) {
267
268
let participants = quorum_met. unwrap ( ) ;
@@ -600,7 +601,9 @@ mod tests {
600
601
601
602
let now = Instant :: now ( ) ;
602
603
603
- assert ! ( !quorum_compute( now, & state, & opt) . 0 . is_some( ) ) ;
604
+ let ( quorum_met, reason) = quorum_compute ( now, & state, & opt) ;
605
+ assert ! ( quorum_met. is_none( ) , "{}" , reason) ;
606
+ assert ! ( reason. contains( "New quorum not ready, only have 0 participants, need min_replicas 1 [0/0 participants healthy]" ) , "{}" , reason) ;
604
607
605
608
state. participants . insert (
606
609
"a" . to_string ( ) ,
@@ -689,7 +692,13 @@ mod tests {
689
692
) ;
690
693
state. heartbeats . insert ( "a" . to_string ( ) , now) ;
691
694
692
- assert ! ( quorum_compute( now, & state, & opt) . 0 . is_some( ) ) ;
695
+ let ( quorum_met, reason) = quorum_compute ( now, & state, & opt) ;
696
+ assert ! ( quorum_met. is_some( ) , "{}" , reason) ;
697
+ assert ! (
698
+ reason. contains( "[1/1 participants healthy][1 heartbeating]" ) ,
699
+ "{}" ,
700
+ reason
701
+ ) ;
693
702
694
703
// expired heartbeat
695
704
state
@@ -698,6 +707,11 @@ mod tests {
698
707
699
708
let ( quorum_met, reason) = quorum_compute ( now, & state, & opt) ;
700
709
assert ! ( quorum_met. is_none( ) , "{}" , reason) ;
710
+ assert ! (
711
+ reason. contains( "[0/1 participants healthy][0 heartbeating]" ) ,
712
+ "{}" ,
713
+ reason
714
+ ) ;
701
715
702
716
// 1 healthy, 1 expired
703
717
state. participants . insert (
@@ -886,6 +900,7 @@ mod tests {
886
900
887
901
let ( quorum_met, reason) = quorum_compute ( now, & state, & opt) ;
888
902
assert ! ( quorum_met. is_some( ) , "{}" , reason) ;
903
+ assert ! ( reason. contains( "[shrink_only=true]" , ) , "{}" , reason) ;
889
904
890
905
let quorum = quorum_met. unwrap ( ) ;
891
906
assert ! ( quorum. len( ) == 1 ) ;
@@ -982,7 +997,7 @@ mod tests {
982
997
state. heartbeats . insert ( "b" . to_string ( ) , now) ;
983
998
let ( quorum_met, reason) = quorum_compute ( now, & state, & opt) ;
984
999
assert ! ( quorum_met. is_none( ) , "{}" , reason) ;
985
- assert ! ( reason. contains( "at least half" ) , "{}" , reason) ;
1000
+ assert ! ( reason. contains( "New quorum not ready, only have 1 participants, need at least half of 2 healthy workers [1/1 participants healthy][2 heartbeating] " ) , "{}" , reason) ;
986
1001
987
1002
Ok ( ( ) )
988
1003
}
0 commit comments