@ -58,6 +58,7 @@ func (h *Head) loadWAL(r *wlog.Reader, syms *labels.SymbolTable, multiRef map[ch
var unknownExemplarRefs atomic . Uint64
var unknownHistogramRefs atomic . Uint64
var unknownMetadataRefs atomic . Uint64
var unknownCustomValuesRefs atomic . Uint64
// Track number of series records that had overlapping m-map chunks.
var mmapOverlappingChunks atomic . Uint64
@ -81,6 +82,7 @@ func (h *Head) loadWAL(r *wlog.Reader, syms *labels.SymbolTable, multiRef map[ch
histogramsPool zeropool . Pool [ [ ] record . RefHistogramSample ]
floatHistogramsPool zeropool . Pool [ [ ] record . RefFloatHistogramSample ]
metadataPool zeropool . Pool [ [ ] record . RefMetadata ]
customValuesPool zeropool . Pool [ [ ] record . RefCustomValues ]
)
defer func ( ) {
@ -223,6 +225,18 @@ func (h *Head) loadWAL(r *wlog.Reader, syms *labels.SymbolTable, multiRef map[ch
return
}
decoded <- meta
case record . CustomValues :
customVals := customValuesPool . Get ( ) [ : 0 ]
customVals , err := dec . CustomValues ( rec , customVals )
if err != nil {
decodeErr = & wlog . CorruptionErr {
Err : fmt . Errorf ( "decode custom values: %w" , err ) ,
Segment : r . Segment ( ) ,
Offset : r . Offset ( ) ,
}
return
}
decoded <- customVals
default :
// Noop.
}
@ -331,6 +345,19 @@ Outer:
if r , ok := multiRef [ sam . Ref ] ; ok {
sam . Ref = r
}
if histogram . IsCustomBucketsSchema ( sam . H . Schema ) {
ms := h . series . getByID ( sam . Ref )
if ms == nil {
unknownHistogramRefs . Inc ( )
continue
}
if ms . lastFloatHistogramValue != nil {
sam . H . CustomValues = ms . lastFloatHistogramValue . CustomValues
} else {
sam . H . CustomValues = ms . customValues
}
}
mod := uint64 ( sam . Ref ) % uint64 ( concurrency )
histogramShards [ mod ] = append ( histogramShards [ mod ] , histogramRecord { ref : sam . Ref , t : sam . T , h : sam . H } )
}
@ -367,6 +394,14 @@ Outer:
if r , ok := multiRef [ sam . Ref ] ; ok {
sam . Ref = r
}
if histogram . IsCustomBucketsSchema ( sam . FH . Schema ) {
ms := h . series . getByID ( sam . Ref )
if ms == nil {
unknownHistogramRefs . Inc ( )
continue
}
sam . FH . CustomValues = ms . customValues
}
mod := uint64 ( sam . Ref ) % uint64 ( concurrency )
histogramShards [ mod ] = append ( histogramShards [ mod ] , histogramRecord { ref : sam . Ref , t : sam . T , fh : sam . FH } )
}
@ -393,6 +428,29 @@ Outer:
}
}
metadataPool . Put ( v )
case [ ] record . RefCustomValues :
for _ , cv := range v {
s := h . series . getByID ( cv . Ref )
if s == nil {
unknownCustomValuesRefs . Inc ( )
continue
}
//TODO: do we actually want to check lastFloatHistogramValue?
if s . lastHistogramValue == nil && s . lastFloatHistogramValue == nil {
s . customValues = cv . CustomValues
}
}
customValuesPool . Put ( v )
// iterate over custom value records and do same things as for series/samples - put them in correct processor
// processor depends on series ref
// something like this:
// idx := uint64(mSeries.ref) % uint64(concurrency)
// processors[idx].input <- walSubsetProcessorInputItem{customValues: }
//for _, cv := range v {
// idx := uint64(cv.Ref) % uint64(concurrency)
// processors[idx].input <- walSubsetProcessorInputItem{customValues: cv}
//}
//customValuesPool.Put(v)
default :
panic ( fmt . Errorf ( "unexpected decoded type: %T" , d ) )
}
@ -616,10 +674,25 @@ func (wp *walSubsetProcessor) processWALSamples(h *Head, mmappedChunks, oooMmapp
if s . t <= ms . mmMaxTime {
continue
}
var chunkCreated bool
if s . h != nil {
//if histogram.IsCustomBucketsSchema(s.h.Schema) {
// if ms.lastHistogramValue != nil {
//
// }
//}
_ , chunkCreated = ms . appendHistogram ( s . t , s . h , 0 , appendChunkOpts )
} else {
//if histogram.IsCustomBucketsSchema(s.fh.Schema) {
// if ms.lastFloatHistogramValue != nil {
// s.h.CustomValues = ms.lastFloatHistogramValue.CustomValues
// } else {
// s.h.CustomValues = ms.customValues
// }
// //customVals := h.
// //s.h.CustomValues =
//}
_ , chunkCreated = ms . appendFloatHistogram ( s . t , s . fh , 0 , appendChunkOpts )
}
if chunkCreated {
@ -647,7 +720,7 @@ func (wp *walSubsetProcessor) processWALSamples(h *Head, mmappedChunks, oooMmapp
func ( h * Head ) loadWBL ( r * wlog . Reader , syms * labels . SymbolTable , multiRef map [ chunks . HeadSeriesRef ] chunks . HeadSeriesRef , lastMmapRef chunks . ChunkDiskMapperRef ) ( err error ) {
// Track number of samples, histogram samples, m-map markers, that referenced a series we don't know about
// for error reporting.
var unknownRefs , unknownHistogramRefs , mmapMarkerUnknownRefs atomic . Uint64
var unknownRefs , unknownHistogramRefs , unknownCustomValuesRefs , mmapMarkerUnknownRefs atomic . Uint64
lastSeq , lastOff := lastMmapRef . Unpack ( )
// Start workers that each process samples for a partition of the series ID space.
@ -747,6 +820,18 @@ func (h *Head) loadWBL(r *wlog.Reader, syms *labels.SymbolTable, multiRef map[ch
return
}
decodedCh <- hists
case record . CustomValues :
customVals := customValuesPool . Get ( ) . ( [ ] record . RefCustomValues ) [ : 0 ]
customVals , err := dec . CustomValues ( rec , customVals )
if err != nil {
decodeErr = & wlog . CorruptionErr {
Err : fmt . Errorf ( "decode custom values: %w" , err ) ,
Segment : r . Segment ( ) ,
Offset : r . Offset ( ) ,
}
return
}
decodedCh <- customVals
default :
// Noop.
}
@ -831,6 +916,18 @@ func (h *Head) loadWBL(r *wlog.Reader, syms *labels.SymbolTable, multiRef map[ch
if r , ok := multiRef [ sam . Ref ] ; ok {
sam . Ref = r
}
if histogram . IsCustomBucketsSchema ( sam . H . Schema ) {
ms := h . series . getByID ( sam . Ref )
if ms == nil {
unknownHistogramRefs . Inc ( )
continue
}
if ms . lastFloatHistogramValue != nil {
sam . H . CustomValues = ms . lastFloatHistogramValue . CustomValues
} else {
sam . H . CustomValues = ms . customValues
}
}
mod := uint64 ( sam . Ref ) % uint64 ( concurrency )
histogramShards [ mod ] = append ( histogramShards [ mod ] , histogramRecord { ref : sam . Ref , t : sam . T , h : sam . H } )
}
@ -863,6 +960,14 @@ func (h *Head) loadWBL(r *wlog.Reader, syms *labels.SymbolTable, multiRef map[ch
if r , ok := multiRef [ sam . Ref ] ; ok {
sam . Ref = r
}
if histogram . IsCustomBucketsSchema ( sam . FH . Schema ) {
ms := h . series . getByID ( sam . Ref )
if ms == nil {
unknownHistogramRefs . Inc ( )
continue
}
sam . FH . CustomValues = ms . customValues
}
mod := uint64 ( sam . Ref ) % uint64 ( concurrency )
histogramShards [ mod ] = append ( histogramShards [ mod ] , histogramRecord { ref : sam . Ref , t : sam . T , fh : sam . FH } )
}