@@ -447,6 +447,23 @@ type RaftConfig struct {
447
447
// begin performing log truncations.
448
448
RaftLogTruncationThreshold int64
449
449
450
+ // RaftProposalQuota controls the maximum aggregate size of Raft commands
451
+ // that a leader is allowed to propose concurrently.
452
+ //
453
+ // By default, the quota is set to a fraction of the Raft log truncation
454
+ // threshold. In doing so, we ensure all replicas have sufficiently up to
455
+ // date logs so that when the log gets truncated, the followers do not need
456
+ // non-preemptive snapshots. Changing this deserves care. Too low and
457
+ // everything comes to a grinding halt, too high and we're not really
458
+ // throttling anything (we'll still generate snapshots).
459
+ RaftProposalQuota int64
460
+
461
+ // RaftMaxUncommittedEntriesSize controls how large the uncommitted tail of
462
+ // the Raft log can grow. The limit is meant to provide protection against
463
+ // unbounded Raft log growth when quorum is lost and entries stop being
464
+ // committed but continue to be proposed.
465
+ RaftMaxUncommittedEntriesSize uint64
466
+
450
467
// RaftMaxSizePerMsg controls how many Raft log entries the leader will send to
451
468
// followers in a single MsgApp.
452
469
RaftMaxSizePerMsg uint64
@@ -475,6 +492,18 @@ func (cfg *RaftConfig) SetDefaults() {
475
492
if cfg .RaftLogTruncationThreshold == 0 {
476
493
cfg .RaftLogTruncationThreshold = defaultRaftLogTruncationThreshold
477
494
}
495
+ if cfg .RaftProposalQuota == 0 {
496
+ // By default, set this to a fraction of RaftLogMaxSize. See the comment
497
+ // on the field for the tradeoffs of setting this higher or lower.
498
+ cfg .RaftProposalQuota = cfg .RaftLogTruncationThreshold / 4
499
+ }
500
+ if cfg .RaftMaxUncommittedEntriesSize == 0 {
501
+ // By default, set this to twice the RaftProposalQuota. The logic here
502
+ // is that the quotaPool should be responsible for throttling proposals
503
+ // in all cases except for unbounded Raft re-proposals because it queues
504
+ // efficiently instead of dropping proposals on the floor indiscriminately.
505
+ cfg .RaftMaxUncommittedEntriesSize = uint64 (2 * cfg .RaftProposalQuota )
506
+ }
478
507
if cfg .RaftMaxSizePerMsg == 0 {
479
508
cfg .RaftMaxSizePerMsg = uint64 (defaultRaftMaxSizePerMsg )
480
509
}
0 commit comments