diff --git a/pkg/ingester/ingester.go b/pkg/ingester/ingester.go index 516d7ec7033..42396fe5166 100644 --- a/pkg/ingester/ingester.go +++ b/pkg/ingester/ingester.go @@ -2570,7 +2570,7 @@ func (i *Ingester) createTSDB(userID string, walReplayConcurrency int) (*userTSD localSeriesLimit: initialLocalLimit, }, } - userDB.resetSymbolTable() + userDB.resetSymbolTable(i.logger) userDB.triggerRecomputeOwnedSeries(recomputeOwnedSeriesReasonNewUser) oooTW := i.limits.OutOfOrderTimeWindow(userID) @@ -3089,7 +3089,7 @@ func (i *Ingester) compactBlocks(ctx context.Context, force bool, forcedCompacti default: reason = "regular" err = userDB.Compact() - userDB.resetSymbolTable() + userDB.resetSymbolTable(i.logger) } if err != nil { diff --git a/pkg/ingester/user_tsdb.go b/pkg/ingester/user_tsdb.go index bb553935090..dde84372bd6 100644 --- a/pkg/ingester/user_tsdb.go +++ b/pkg/ingester/user_tsdb.go @@ -11,6 +11,7 @@ import ( "math" "sync" "time" + "unsafe" "github.com/go-kit/log" "github.com/go-kit/log/level" @@ -629,11 +630,20 @@ func (u *userTSDB) computeOwnedSeries() int { return count } -func (u *userTSDB) resetSymbolTable() { +type hackSymbolTable struct { + mx sync.Mutex + p unsafe.Pointer + nextNum int +} + +func (u *userTSDB) resetSymbolTable(logger log.Logger) { var st *labels.SymbolTable if u.db != nil && u.db.Head() != nil { + level.Info(logger).Log("msg", "RebuildSymbolTable starting") // Compact all labels in head into one SymbolTable. st = u.Head().RebuildSymbolTable() + x := (*hackSymbolTable)(unsafe.Pointer(st)) + level.Info(logger).Log("msg", "RebuildSymbolTable finished", "addr", fmt.Sprintf("%p: %v", x, x), "size", st.Len()) } else { st = labels.NewSymbolTable() }