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

txn: remove the schema check and safe window related utilities after MDL is introduced #39196

Open
cfzjywxk opened this issue Nov 16, 2022 · 0 comments
Labels
type/enhancement The issue or PR belongs to an enhancement.

Comments

@cfzjywxk
Copy link
Contributor

cfzjywxk commented Nov 16, 2022

Enhancement

The schema checker and safe window are used to ensure the related schema version would not be changed in a transaction lifecycle. After the meta data lock mechanism is introduced in TiDB, it's guaranteed by the DDL module by default, so it's unnecessary to do extra schema checks. After removing these checks:

  1. The backfill job is no longer blocked by the safe window, and the DDL statement executes faster.
  2. The async commit/1pc transactions are no longer constrained by a max_commit_ts related to the safe window interval.
  3. The schema lease checker could be removed from the kv client.

Previously when a transaction is being committed, it would check the schema versions of related tables, the commit would fail if there were any version changes. Besides, this checking requires a current valid schema version and the check would fail if the version has uncertainties.

Safety:

  1. For 2PC transactions, the commit statement finishes after the primary key is committed, so it's safe to remove the schema checker directly.
  2. For async commit/1PC transactions, the prewrite phase must be finished after the commit statement finishes and there must be a prewrite lock on the corresponding keys, the transaction state must be committed which is ensured by the committing protocol. The related table schema version could not be pushed forward as any DDL operations requiring data reorganization would conflict with the existing prewrite lock, so the commit is still safe. For DDL operations that do not require data reorganization, it's always safe to commit using older schema versions.

Note after removing these checks, the new checking logic is relaxed a lot compared with the previous utilities, it's better to review the test cases and there could be behavior and test result changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

No branches or pull requests

1 participant