Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improvement] stats: add some logs and UT #20620

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/cnservice/server_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ func (s *service) handleFaultInjection(ctx context.Context, req *query.Request,
}

func (s *service) handleMoTableStats(ctx context.Context, req *query.Request, resp *query.Response, _ *morpc.Buffer) error {
ret := disttae.HandleMoTableStatsCtl(req.CtlMoTableStatsRequest.Cmd)
e := s.storeEngine.(*disttae.Engine)
ret := e.HandleMoTableStatsCtl(req.CtlMoTableStatsRequest.Cmd)
resp.CtlMoTableStatsResponse = query.CtlMoTableStatsResponse{
Resp: ret,
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/frontend/show_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ func updateStorageUsageCache(usages *cmd_util.StorageUsageResp_V3) {

func tryGetSizeFromMTS(
ctx context.Context,
serviceID string,
accIds [][]int64,
) (sizes map[int64]uint64, ok bool) {

Expand All @@ -340,7 +341,7 @@ func tryGetSizeFromMTS(
}
}

vals, accs, err, ok = disttae.QueryTableStatsByAccounts(
vals, accs, err, ok = getPu(serviceID).StorageEngine.QueryTableStatsByAccounts(
ctx,
[]int{disttae.TableStatsTableSize},
accs,
Expand Down Expand Up @@ -385,7 +386,7 @@ func getAccountsStorageUsage(
return
}

sizes, ok := tryGetSizeFromMTS(ctx, accIds)
sizes, ok := tryGetSizeFromMTS(ctx, ses.service, accIds)
if ok {
for k, v := range sizes {
if len(ret[k]) == 0 {
Expand Down
17 changes: 17 additions & 0 deletions pkg/frontend/test/engine_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion pkg/vm/engine/disttae/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,22 @@ func New(
e.pClient.LogtailRPCClientFactory = DefaultNewRpcStreamToTnLogTailService
e.pClient.ctx = ctx

initMoTableStatsConfig(ctx, e)
err = initMoTableStatsConfig(ctx, e)
if err != nil {
panic(err)
}

return e
}

func (e *Engine) Close() error {
if e.gcPool != nil {
e.gcPool.Release()
}
e.dynamicCtx.Close()
return nil
}

func (e *Engine) fillDefaults() {
if e.config.insertEntryMaxCount <= 0 {
e.config.insertEntryMaxCount = InsertEntryThreshold
Expand Down
10 changes: 9 additions & 1 deletion pkg/vm/engine/disttae/logtail_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,12 @@ func (c *PushClient) receiveLogtails(ctx context.Context, e *Engine) {
}

// Wait for resuming logtail receiver.
<-c.resumeC
select {
case <-ctx.Done():
return

case <-c.resumeC:
}
logutil.Infof("%s logtail receiver resumed", logTag)

default:
Expand Down Expand Up @@ -1835,6 +1840,9 @@ func (c *PushClient) createRoutineToConsumeLogTails(
errHappen := false
for {
select {
case <-ctx.Done():
return

case cmd := <-receiver.signalChan:
if errHappen {
continue
Expand Down
Loading
Loading