@@ -93,13 +93,13 @@ type Progress struct {
93
93
// This is always true on the leader.
94
94
RecentActive bool
95
95
96
- // MsgAppFlowPaused is used when the MsgApp flow to a node is throttled. This
97
- // happens in StateProbe, or StateReplicate with saturated Inflights. In both
98
- // cases, we need to continue sending MsgApp once in a while to guarantee
99
- // progress, but we only do so when MsgAppFlowPaused is false (it is reset on
100
- // receiving a heartbeat response), to not overflow the receiver. See
101
- // IsPaused ().
102
- MsgAppFlowPaused bool
96
+ // MsgAppProbesPaused set to true prevents sending "probe" MsgApp messages to
97
+ // this follower. Used in StateProbe, or StateReplicate when all entries are
98
+ // in-flight or the in-flight volume exceeds limits. See ShouldSendMsgApp().
99
+ //
100
+ // TODO(pav-kv): unexport this field. It is used by a few tests, but should be
101
+ // replaced by PauseMsgAppProbes() and ShouldSendMsgApp ().
102
+ MsgAppProbesPaused bool
103
103
104
104
// Inflights is a sliding window for the inflight messages.
105
105
// Each inflight message contains one or more log entries.
@@ -119,7 +119,7 @@ type Progress struct {
119
119
IsLearner bool
120
120
}
121
121
122
- // ResetState moves the Progress into the specified State, resetting MsgAppFlowPaused ,
122
+ // ResetState moves the Progress into the specified State, resetting MsgAppProbesPaused ,
123
123
// PendingSnapshot, and Inflights.
124
124
func (pr * Progress ) ResetState (state StateType ) {
125
125
pr .PauseMsgAppProbes (false )
@@ -176,7 +176,7 @@ func (pr *Progress) SentEntries(entries int, bytes uint64) {
176
176
// PauseMsgAppProbes pauses or unpauses empty MsgApp messages flow, depending on
177
177
// the passed-in bool.
178
178
func (pr * Progress ) PauseMsgAppProbes (pause bool ) {
179
- pr .MsgAppFlowPaused = pause
179
+ pr .MsgAppProbesPaused = pause
180
180
}
181
181
182
182
// CanSendEntries returns true if the flow control state allows sending at least
@@ -261,12 +261,17 @@ func (pr *Progress) MaybeDecrTo(rejected, matchHint uint64) bool {
261
261
// operation, this is false. A throttled node will be contacted less frequently
262
262
// until it has reached a state in which it's able to accept a steady stream of
263
263
// log entries again.
264
+ //
265
+ // TODO(pav-kv): this method is deprecated, remove it. It is still used in tests
266
+ // and String(), find a way to avoid this. The problem is that the actual flow
267
+ // control state depends on the log size and commit index, which are not part of
268
+ // this Progress struct - they are passed-in to methods like ShouldSendMsgApp().
264
269
func (pr * Progress ) IsPaused () bool {
265
270
switch pr .State {
266
271
case StateProbe :
267
- return pr .MsgAppFlowPaused
272
+ return pr .MsgAppProbesPaused
268
273
case StateReplicate :
269
- return pr .MsgAppFlowPaused && pr .Inflights .Full ()
274
+ return pr .MsgAppProbesPaused && pr .Inflights .Full ()
270
275
case StateSnapshot :
271
276
return true
272
277
default :
@@ -296,10 +301,10 @@ func (pr *Progress) IsPaused() bool {
296
301
func (pr * Progress ) ShouldSendMsgApp (last , commit uint64 ) bool {
297
302
switch pr .State {
298
303
case StateProbe :
299
- return ! pr .MsgAppFlowPaused
304
+ return ! pr .MsgAppProbesPaused
300
305
case StateReplicate :
301
306
return pr .CanBumpCommit (commit ) ||
302
- pr .Match < last && (! pr .MsgAppFlowPaused || pr .CanSendEntries (last ))
307
+ pr .Match < last && (! pr .MsgAppProbesPaused || pr .CanSendEntries (last ))
303
308
case StateSnapshot :
304
309
return false
305
310
default :
0 commit comments