Explorar el Código

wal: not return ErrIndexNotFound in ReadAll

This IndexNotFound case is reasonable now because we don't write dummy
entries into wals any more.
Yicheng Qin hace 11 años
padre
commit
aa61009560
Se han modificado 2 ficheros con 2 adiciones y 7 borrados
  1. 0 5
      wal/wal.go
  2. 2 2
      wal/wal_test.go

+ 0 - 5
wal/wal.go

@@ -46,7 +46,6 @@ const (
 var (
 var (
 	ErrMetadataConflict = errors.New("wal: conflicting metadata found")
 	ErrMetadataConflict = errors.New("wal: conflicting metadata found")
 	ErrFileNotFound     = errors.New("wal: file not found")
 	ErrFileNotFound     = errors.New("wal: file not found")
-	ErrIndexNotFound    = errors.New("wal: index not found in file")
 	ErrCRCMismatch      = errors.New("wal: crc mismatch")
 	ErrCRCMismatch      = errors.New("wal: crc mismatch")
 	crcTable            = crc32.MakeTable(crc32.Castagnoli)
 	crcTable            = crc32.MakeTable(crc32.Castagnoli)
 )
 )
@@ -204,10 +203,6 @@ func (w *WAL) ReadAll() (metadata []byte, state raftpb.HardState, ents []raftpb.
 		state.Reset()
 		state.Reset()
 		return nil, state, nil, err
 		return nil, state, nil, err
 	}
 	}
-	if w.enti < w.ri {
-		state.Reset()
-		return nil, state, nil, ErrIndexNotFound
-	}
 
 
 	// close decoder, disable reading
 	// close decoder, disable reading
 	w.decoder.close()
 	w.decoder.close()

+ 2 - 2
wal/wal_test.go

@@ -364,8 +364,8 @@ func TestOpenAtUncommittedIndex(t *testing.T) {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 	// commit up to index 0, try to read index 1
 	// commit up to index 0, try to read index 1
-	if _, _, _, err := w.ReadAll(); err != ErrIndexNotFound {
-		t.Errorf("err = %v, want %v", err, ErrIndexNotFound)
+	if _, _, _, err := w.ReadAll(); err != nil {
+		t.Errorf("err = %v, want nil", err)
 	}
 	}
 	w.Close()
 	w.Close()
 }
 }