MCPcopy
hub / github.com/prometheus/prometheus / removeCorruptedMmappedChunks

Method removeCorruptedMmappedChunks

tsdb/head.go:1057–1085  ·  view source on GitHub ↗

removeCorruptedMmappedChunks attempts to delete the corrupted mmapped chunks and if it fails, it clears all the previously loaded mmapped chunks.

(err error)

Source from the content-addressed store, hash-verified

1055// removeCorruptedMmappedChunks attempts to delete the corrupted mmapped chunks and if it fails, it clears all the previously
1056// loaded mmapped chunks.
1057func (h *Head) removeCorruptedMmappedChunks(err error) (map[chunks.HeadSeriesRef][]*mmappedChunk, map[chunks.HeadSeriesRef][]*mmappedChunk, chunks.ChunkDiskMapperRef, error) {
1058 h.logger.Info("Deleting mmapped chunk files")
1059 // We never want to preserve the in-memory series from snapshots if we are repairing m-map chunks.
1060 if err := h.resetInMemoryState(); err != nil {
1061 return map[chunks.HeadSeriesRef][]*mmappedChunk{}, map[chunks.HeadSeriesRef][]*mmappedChunk{}, 0, err
1062 }
1063
1064 h.logger.Info("Deleting mmapped chunk files")
1065
1066 if err := h.chunkDiskMapper.DeleteCorrupted(err); err != nil {
1067 h.logger.Info("Deletion of corrupted mmap chunk files failed, discarding chunk files completely", "err", err)
1068 if err := h.chunkDiskMapper.Truncate(math.MaxUint32); err != nil {
1069 h.logger.Error("Deletion of all mmap chunk files failed", "err", err)
1070 }
1071 return map[chunks.HeadSeriesRef][]*mmappedChunk{}, map[chunks.HeadSeriesRef][]*mmappedChunk{}, 0, nil
1072 }
1073
1074 h.logger.Info("Deletion of mmap chunk files successful, reattempting m-mapping the on-disk chunks")
1075 mmappedChunks, oooMmappedChunks, lastRef, err := h.loadMmappedChunks(make(map[chunks.HeadSeriesRef]*memSeries))
1076 if err != nil {
1077 h.logger.Error("Loading on-disk chunks failed, discarding chunk files completely", "err", err)
1078 if err := h.chunkDiskMapper.Truncate(math.MaxUint32); err != nil {
1079 h.logger.Error("Deletion of all mmap chunk files failed after failed loading", "err", err)
1080 }
1081 mmappedChunks = map[chunks.HeadSeriesRef][]*mmappedChunk{}
1082 }
1083
1084 return mmappedChunks, oooMmappedChunks, lastRef, nil
1085}
1086
1087func (h *Head) ApplyConfig(cfg *config.Config, wbl *wlog.WL) {
1088 oooTimeWindow := int64(0)

Callers 1

InitMethod · 0.95

Calls 5

resetInMemoryStateMethod · 0.95
loadMmappedChunksMethod · 0.95
DeleteCorruptedMethod · 0.80
ErrorMethod · 0.65
TruncateMethod · 0.45

Tested by

no test coverage detected