mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-08-21 22:56:55 +00:00
fix: add nil check for RetainedHistory in sender APIs
RecordHandshakeFromHistory and SelectRebuildFromHistory now return an error instead of panicking on nil history input. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
cc8c529962
commit
4d06622c01
@@ -272,6 +272,9 @@ func (s *Sender) RecordHandshakeWithOutcome(sessionID uint64, result HandshakeRe
|
||||
// preferred engine-level API — it ensures recovery decisions are backed
|
||||
// by actual retention state, not caller-supplied values.
|
||||
func (s *Sender) RecordHandshakeFromHistory(sessionID uint64, replicaFlushedLSN uint64, history *RetainedHistory) (RecoveryOutcome, *RecoverabilityProof, error) {
|
||||
if history == nil {
|
||||
return OutcomeNeedsRebuild, nil, fmt.Errorf("nil RetainedHistory")
|
||||
}
|
||||
proof := history.ProveRecoverability(replicaFlushedLSN)
|
||||
hr := history.MakeHandshakeResult(replicaFlushedLSN)
|
||||
outcome, err := s.RecordHandshakeWithOutcome(sessionID, hr)
|
||||
@@ -283,6 +286,9 @@ func (s *Sender) RecordHandshakeFromHistory(sessionID uint64, replicaFlushedLSN
|
||||
// the rebuild-source decision accounts for both checkpoint trust AND
|
||||
// tail replayability.
|
||||
func (s *Sender) SelectRebuildFromHistory(sessionID uint64, history *RetainedHistory) error {
|
||||
if history == nil {
|
||||
return fmt.Errorf("nil RetainedHistory")
|
||||
}
|
||||
source, snapLSN := history.RebuildSourceDecision()
|
||||
valid := source == RebuildSnapshotTail
|
||||
return s.SelectRebuildSource(sessionID, snapLSN, valid, history.CommittedLSN)
|
||||
|
||||
Reference in New Issue
Block a user