Skip to content

Don't print error log for indexLookUpExecutor when context canceled #61072

@yibin87

Description

@yibin87

Enhancement

When indexLookUpExecutor is closed before its index/table worker finished(it may be caused by limit operator), it will use cancelFunc to inform index/tableWork. Currently, this will lead to useless error logs: "[2025/05/12 10:25:18.142 +08:00] [ERROR] [distsql.go:1572] ["table reader fetch next chunk failed"] [conn=2120221196] [session_alias=] [error="context canceled"]"

  1. LimitExec returns nil when fetches enough rows, and its Close function will be called next:

    tidb/pkg/executor/select.go

    Lines 429 to 431 in 2503d50

    if e.cursor >= e.end {
    return nil
    }
  2. When indexLookUpExecutor's Close function is called, it will call its cancelFunc to inform index/tableWork:
    if e.cancelFunc != nil {
    e.cancelFunc()
    e.cancelFunc = nil
    }
  3. In coprocessor, each time it tries to receive response, it checks the context status, and return error when context canceled:
    resp, ok, closed = it.recvFromRespCh(ctx, it.respChan)
    if !ok || closed {
    it.actionOnExceed.close()
    return nil, errors.Trace(ctx.Err())
    }
  4. In indexLookUpExecutor's tableWork, it outputs error log when errors returned from coprocessor:

    tidb/pkg/executor/distsql.go

    Lines 1564 to 1567 in 2503d50

    if err != nil {
    logutil.Logger(ctx).Error("table reader fetch next chunk failed", zap.Error(err))
    return err
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.affects-8.5This bug affects the 8.5.x(LTS) versions.report/customerCustomers have encountered this bug.sig/executionSIG executiontype/enhancementThe issue or PR belongs to an enhancement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions