storage/remote/wal_watcher.go
func (w *WALWatcher) readCheckpoint(checkpointDir string) error {
	level.Debug(w.logger).Log("msg", "reading checkpoint", "dir", checkpointDir)
	index, err := checkpointNum(checkpointDir)
	if err != nil {
		return errors.Wrap(err, "checkpointNum")
	}

	// Ensure we read the whole contents of every segment in the checkpoint dir.
	segs, err := w.segments(checkpointDir)
	if err != nil {
		return errors.Wrap(err, "Unable to get segments checkpoint dir")
	}
	for _, seg := range segs {
		size, err := getSegmentSize(checkpointDir, seg)
		if err != nil {
			return errors.Wrap(err, "getSegmentSize")
		}

		sr, err := wal.OpenReadSegment(wal.SegmentName(checkpointDir, seg))
		if err != nil {
			return errors.Wrap(err, "unable to open segment")
		}
		defer sr.Close()

		r := wal.NewLiveReader(w.logger, sr)
		if err := w.readSegment(r, index, false); err != io.EOF && err != nil {
			return errors.Wrap(err, "readSegment")
		}

		if r.Offset() != size {
			return fmt.Errorf("readCheckpoint wasn't able to read all data from the checkpoint %s/%08d, size: %d, totalRead: %d", checkpointDir, seg, size, r.Offset())
		}
	}

	level.Debug(w.logger).Log("msg", "read series references from checkpoint", "checkpoint", checkpointDir)
	return nil
}
func (w *WALWatcher) readCheckpoint(checkpointDir string) error {
	level.Debug(w.logger).Log("msg", "reading checkpoint", "dir", checkpointDir)
	index, err := checkpointNum(checkpointDir)
	if err != nil {
		return errors.Wrap(err, "checkpointNum")
	}

	// Ensure we read the whole contents of every segment in the checkpoint dir.
	segs, err := w.segments(checkpointDir)
	if err != nil {
		return errors.Wrap(err, "Unable to get segments checkpoint dir")
	}
	for _, seg := range segs {
		size, err := getSegmentSize(checkpointDir, seg)
		if err != nil {
			return errors.Wrap(err, "getSegmentSize")
		}

		sr, err := wal.OpenReadSegment(wal.SegmentName(checkpointDir, seg))
		if err != nil {
			return errors.Wrap(err, "unable to open segment")
		}
		defer sr.Close()

		r := wal.NewLiveReader(w.logger, sr)
		if err := w.readSegment(r, index, false); err != io.EOF && err != nil {
			return errors.Wrap(err, "readSegment")
		}

		if r.Offset() != size {
			return fmt.Errorf("readCheckpoint wasn't able to read all data from the checkpoint %s/%08d, size: %d, totalRead: %d", checkpointDir, seg, size, r.Offset())
		}
	}

	level.Debug(w.logger).Log("msg", "read series references from checkpoint", "checkpoint", checkpointDir)
	return nil
}
func ( w * WALWatcher ) readCheckpoint ( checkpointDir string ) error { level . Debug ( w . logger ) . Log ( " " , " " , " " , checkpointDir ) index , err := checkpointNum ( checkpointDir ) if err != nil { return errors . Wrap ( err , " " ) } // Ensure we read the whole contents of every segment in the checkpoint dir. segs , err := w . segments ( checkpointDir ) if err != nil { return errors . Wrap ( err , " " ) } for _ , seg := range segs { size , err := getSegmentSize ( checkpointDir , seg ) if err != nil { return errors . Wrap ( err , " " ) } sr , err := wal . OpenReadSegment ( wal . SegmentName ( checkpointDir , seg ) ) if err != nil { return errors . Wrap ( err , " " ) } defer sr . Close ( ) r := wal . NewLiveReader ( w . logger , sr ) if err := w . readSegment ( r , index , false ) ; err != io . EOF && err != nil { return errors . Wrap ( err , " " ) } if r . Offset ( ) != size { return fmt . Errorf ( " " , checkpointDir , seg , size , r . Offset ( ) ) } } level . Debug ( w . logger ) . Log ( " " , " " , " " , checkpointDir ) return nil }
// Read all the series records from a Checkpoint directory.
Read all the series records from a Checkpoint directory .