Browse Source

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>
pull/8075/head
Jupiter 3 years ago committed by GitHub
parent
commit
7337ecf0d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      tsdb/index/index.go

8
tsdb/index/index.go

@ -523,9 +523,15 @@ func (w *Writer) AddSymbol(sym string) 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.
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))
if err := w.writeAt(w.buf1.Get(), w.toc.Symbols); err != nil {
return err

Loading…
Cancel
Save