mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34:05 -08:00
Log when total symbol size exceeds 2^32 bytes. (#9104)
* Compaction fails when total symbol size exceeds 2^32 bytes. Signed-off-by: tanghengjian <1040104807@qq.com> * Compaction fails when total symbol size exceeds 2^32 bytes. Signed-off-by: tanghengjian <1040104807@qq.com> * Compaction fails when total symbol size exceeds 2^32 bytes. Signed-off-by: root <tanghengjian@oppo.com> Co-authored-by: root <tanghengjian@oppo.com>
This commit is contained in:
parent
59d02b5ef0
commit
7337ecf0d3
|
@ -523,9 +523,15 @@ func (w *Writer) AddSymbol(sym string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Writer) finishSymbols() error {
|
func (w *Writer) finishSymbols() error {
|
||||||
|
symbolTableSize := w.f.pos - w.toc.Symbols - 4
|
||||||
|
// The symbol table's <len> part is 4 bytes. So the total symbol table size must be less than or equal to 2^32-1
|
||||||
|
if symbolTableSize > 4294967295 {
|
||||||
|
return errors.Errorf("symbol table size exceeds 4 bytes: %d", symbolTableSize)
|
||||||
|
}
|
||||||
|
|
||||||
// Write out the length and symbol count.
|
// Write out the length and symbol count.
|
||||||
w.buf1.Reset()
|
w.buf1.Reset()
|
||||||
w.buf1.PutBE32int(int(w.f.pos - w.toc.Symbols - 4))
|
w.buf1.PutBE32int(int(symbolTableSize))
|
||||||
w.buf1.PutBE32int(int(w.numSymbols))
|
w.buf1.PutBE32int(int(w.numSymbols))
|
||||||
if err := w.writeAt(w.buf1.Get(), w.toc.Symbols); err != nil {
|
if err := w.writeAt(w.buf1.Get(), w.toc.Symbols); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue