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

Provide a method to clone the tableReaderExecutorContext #52847

Open
1 task
YangKeao opened this issue Apr 24, 2024 · 0 comments
Open
1 task

Provide a method to clone the tableReaderExecutorContext #52847

YangKeao opened this issue Apr 24, 2024 · 0 comments

Comments

@YangKeao
Copy link
Member

Enhancement

We already have a small enough tableReaderExecutorContext to be cloned. Let's figure out how to clone each fields of it:

  • *distsqlctx.DistSQLContext. Most of the fields in DistSQLContext is just a value and it's safe to clone. However, there are still some fields that need us to take care of:
    • (Clone) *tikvstore.Variables. I'm not sure why it's a pointer, maybe some fields of it will be changed during execution 🤔 .
    • (Optional) *stmtstats.KvExecCounter. It'll not be re-used for each statement, so it's safe to just use the reference directly.
    • (No) SessionMemTracker *memory.Tracker. As it always points to the memory tracker on session, so it's safe to use the reference directly.
    • (Optional) *execdetails.RuntimeStatsColl. It'll not be re-used, so use the reference directly is safe.
    • (TODO) *sqlkiller.SQLKiller.
    • (Optional) *execdetails.SyncExecDetails. It'll not be re-used, so it's safe to just use the reference directly.
  • *rangerctx.RangerContext. Most of the fields are fine. We only need to re-build it with a cloned WarnHandler. We'll discuss WarnHandler field later.
  • *planctx.BuildPBContext.
    • AppendWarning and AppendExtraWarning. We'll need to refactor them into the WarnHandler before considering clone it.
  • exprctx.BuildContext. We already have StaticEvalContext https://github.com/pingcap/tidb/pull/52631/files
  • (Clone) isctx.MetaOnlyInfoSchema. The base of MetaOnlyInfoSchema is returned from vars.SnapshotInfoschema. It's not safe to use by different statements concurrently. Therefore, it'll need to be cloned.
  • (No) getDDLOwner. The current implementation of getDDLOwner only depends on ownerManager (of ddl), which is safe to be used in multiple statements.

Fields which are used across many contexts

  • Warnhandler. It's widely used in errctx, typectx and many other contexts, which means that we'll need to re-build all these contexts according to the dependency.
  • kv.Client. TODO. I'm not sure whether it can be used in parallel statement safely.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant