@@ -323,6 +323,10 @@ type raft struct {
323323
324324 maxMsgSize entryEncodingSize
325325 maxUncommittedSize entryPayloadSize
326+ // maxCommittedPageSize limits the size of committed entries that can be
327+ // loaded into memory in hasUnappliedConfChanges.
328+ // TODO(#131559): avoid this loading in the first place, and remove this.
329+ maxCommittedPageSize entryEncodingSize
326330
327331 config quorum.Config
328332 trk tracker.ProgressTracker
@@ -445,7 +449,7 @@ func newRaft(c *Config) *raft {
445449 if err := c .validate (); err != nil {
446450 panic (err .Error ())
447451 }
448- raftlog := newLogWithSize (c .Storage , c .Logger , entryEncodingSize ( c . MaxCommittedSizePerReady ) )
452+ raftlog := newLog (c .Storage , c .Logger )
449453 hs , cs , err := c .Storage .InitialState ()
450454 if err != nil {
451455 panic (err ) // TODO(bdarnell)
@@ -457,6 +461,7 @@ func newRaft(c *Config) *raft {
457461 raftLog : raftlog ,
458462 maxMsgSize : entryEncodingSize (c .MaxSizePerMsg ),
459463 maxUncommittedSize : entryPayloadSize (c .MaxUncommittedEntriesSize ),
464+ maxCommittedPageSize : entryEncodingSize (c .MaxCommittedSizePerReady ),
460465 lazyReplication : c .LazyReplication ,
461466 electionTimeout : c .ElectionTick ,
462467 electionTimeoutJitter : c .ElectionJitterTick ,
@@ -1474,13 +1479,7 @@ func (r *raft) hasUnappliedConfChanges() bool {
14741479 // Scan all unapplied committed entries to find a config change. Paginate the
14751480 // scan, to avoid a potentially unlimited memory spike.
14761481 lo , hi := r .raftLog .applied , r .raftLog .committed
1477- // Reuse the maxApplyingEntsSize limit because it is used for similar purposes
1478- // (limiting the read of unapplied committed entries) when raft sends entries
1479- // via the Ready struct for application.
1480- // TODO(pavelkalinnikov): find a way to budget memory/bandwidth for this scan
1481- // outside the raft package.
1482- pageSize := r .raftLog .maxApplyingEntsSize
1483- if err := r .raftLog .scan (lo , hi , pageSize , func (ents []pb.Entry ) error {
1482+ if err := r .raftLog .scan (lo , hi , r .maxCommittedPageSize , func (ents []pb.Entry ) error {
14841483 for i := range ents {
14851484 if ents [i ].Type == pb .EntryConfChange || ents [i ].Type == pb .EntryConfChangeV2 {
14861485 found = true
0 commit comments