You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Document database-level read-only mode for migration cutover and data validation:
Add a feature guide covering read-only state changes, transaction draining, SQL restrictions, explicit privilege bypass, MySQL compatibility, and interactions with import, backup, restore, and replication tools.
Add the INFORMATION_SCHEMA.SCHEMATA_EXTENSIONS reference and query example.
Update ALTER DATABASE, SHOW CREATE DATABASE, privilege descriptions, system-variable cross-references, and navigation entries.
The release-8.5 documentation assumes that pingcap/tidb#73801 has been merged, including SQL restoration of sequences in read-only databases. The first release version remains a TODO for confirmation.
Validation: Markdown formatting, internal links, link anchors, new-page metadata, and git diff --check passed.
Which TiDB version(s) do your changes apply to? (Required)
Tips for choosing the affected version(s):
By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.
The changes in this PR were primarily made by an AI agent on behalf of the PR author.
Do your changes match any of the following descriptions?
Delete files
Change aliases
Need modification after applied to another branch
Might cause conflicts after applied to another branch
Summary by CodeRabbit
Documentation
Added guidance for database-level read-only mode, including how to enable and check it, its effects on transactions and SQL operations, privilege requirements, compatibility limits, interactions with TiDB tools, and recovery steps.
Documented the READ ONLY option for ALTER DATABASE, its supported values, and examples for enabling read-only mode and restoring write access.
Added documentation for INFORMATION_SCHEMA.SCHEMATA_EXTENSIONS, including its columns, database settings, and a query example, with navigation links to related pages.
Clarified how database-level read-only mode interacts with privileges and cluster-wide restrictions, and how it appears in SHOW CREATE DATABASE output.
In response to a cherrypick label: @expxiaoli once the present PR merges, I will cherry-pick it on top of release-8.5 in a new PR and assign it to you.
This pull-request has been approved by: Once this PR has been reviewed and has the lgtm label, please assign tangenta for approval. For more information see the Code Review Process. Please ensure that each of them provides their approval before proceeding.
The full list of commands accepted by this bot can be found here.
Details
Needs approval from an approver in each of these files:
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
The documentation adds coverage for database-level read-only mode, including SQL controls, transaction behavior, restrictions, privileges, tool interactions, and metadata reporting.
Changes: Database-Level Read-Only Mode
Layer / File(s)
Summary
SQL controls and transition behavior TOC.md, database-read-only.md, sql-statements/sql-statement-alter-database.md, sql-statements/sql-statement-show-create-database.md
Documents how to enable, check, and disable database-level read-only mode. Covers transaction behavior and the read-only setting in SHOW CREATE DATABASE output.
Restrictions and privilege behavior database-read-only.md, privilege-management.md, system-variables.md
Documents SQL restrictions, bypass privilege requirements, cluster-wide read-only restrictions, batch-DML behavior, and interactions with TiDB tools.
Metadata and documentation navigation information-schema/information-schema-schemata-extensions.md, information-schema/information-schema.md, TOC.md, database-read-only.md
Documents SCHEMATA_EXTENSIONS, its OPTIONS values, an example, and related navigation links.
The new read-only mode documentation is mostly complete. Before publishing, state the first supported release and qualify the PITR statement for existing target databases, so readers do not rely on read-only protection that may not be present.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title states the primary change: documentation for database-level read-only mode. The changeset adds a feature guide for that mode and updates related references, so the title matches the main cha…
Description check
The description follows the template sections: changes made, TiDB version selection, related PR links, and AI agent involvement. It states the purpose (migration cutover and data validation), lists th…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title states the primary change: documentation for database-level read-only mode. The changeset adds a feature guide for that mode and updates related references, so the title matches the main change.
Full details: Description check
Explanation
The description follows the template sections: changes made, TiDB version selection, related PR links, and AI agent involvement. It states the purpose (migration cutover and data validation), lists the changed areas, and gives the v8.5 dependency on pingcap/tidb#73801 and validation results. The first release version is still a TODO. The template's first-time contributor checklist is omitted, which is non-critical.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Identify the first supported release.
This prerequisite does not tell users which TiDB version supports the feature. They cannot use it to plan an upgrade or restore. Confirm the first release that includes the feature and the sequence restore fix, then state it here. The feature was merged into the release-8.5 branch on November 24, 2026. (github.com)
The reason will be displayed to describe this comment to others. Learn more.
Agreed that the first supported release needs to be stated before publication. The exact release version is still awaiting confirmation, so the existing explicit TODO is retained for now. Merging the feature into release-8.5 alone does not establish which released patch version includes it. The feature and the SQL sequence restore fix need to be checked separately; if their first supported versions differ, the documentation should distinguish them.
The reason will be displayed to describe this comment to others. Learn more.
@expxiaoli A merge into release-8.5 alone does not establish a patch release. Before publication, confirm the first supported release for the feature and the SQL sequence restore fix separately. If they differ, document both versions.
I’m not marking the finding as addressed while the versions remain unconfirmed.
Learnings added
Learnt from: expxiaoli
Repo: pingcap/docs PR: 24769
File: database-read-only.md:16-16
Timestamp: 2026-11-27T07:38:59.738Z
Learning: Within repository "pingcap/docs", only for files matching one of ["database-read-only.md"]: When documenting the first supported TiDB release for database-level read-only mode in `database-read-only.md`, verify the feature and the SQL sequence restore fix separately. A merge into `release-8.5` alone does not establish the released patch version. If their first supported versions differ, document both.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
Reviewing files that changed from the base of the PR and between 0ddb06f and f59a816.
Files selected for processing: 1
database-read-only.md
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
Reviewing files that changed from the base of the PR and between f59a816 and e6e53b6.
Files selected for processing: 1
database-read-only.md
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
I checked the read-only transition and rollback, privilege enforcement, SCHEMATA_EXTENSIONS output, batch DML, and restore behavior against the merged TiDB implementation and its tests. The Markdown, links, and anchors passed CI.
One P2 remains for the release-8.5 documentation: the guide promises SQL restoration of sequences into read-only databases while the required fix is still open. The table should condition that behavior on a release that includes the fix.
| TiDB Lightning | Physical imports using the `local` backend can write directly to TiKV into existing tables despite read-only mode. Control these imports separately. Logical imports obey SQL restrictions. |
| BR and SQL `BACKUP` / `RESTORE` | Snapshot restore preserves backed-up read-only metadata when it creates a database. If the target database already exists, restore retains its current read-only setting. Authorized restores can restore tables and sequences into read-only databases; ordinary writes to read-only databases remain restricted afterward. If you require read-only protection during and after restoring to an existing database, run `ALTER DATABASE ... READ ONLY = 1` and wait for it to complete before starting the restore. If the target database is writable, restored tables can accept ordinary writes before read-only protection takes effect. After restoring, check `INFORMATION_SCHEMA.SCHEMATA_EXTENSIONS`. PITR retains the current read-only setting of reused target databases; do not assume it matches the source setting at the selected time. |
The reason will be displayed to describe this comment to others. Learn more.
[P2] Qualify SQL sequence restore for release-8.5. If an operator follows this row and enables READ ONLY on an existing target before restoring a snapshot containing a sequence, SQL RESTORE can fail while restoring the sequence value. In the release-8.5 feature commit, CreateTablePostRestore grants a schema-scoped bypass on the restore session, but tidbGlueSession.Execute dispatches SETVAL through a pooled session that lacks that bypass. The fix is merged on master, and its release-8.5 backport is still open. Please make the sequence guarantee conditional on a release that contains the fix, especially for the 8.5 cherry-pick. Restore path · SQL execution · 8.5 backport.
The reason will be displayed to describe this comment to others. Learn more.
The fix is already merged on master via pingcap/tidb#73748. The PR description explicitly states that the release-8.5 documentation assumes pingcap/tidb#73801 has been merged. Before cherry-picking the documentation to release-8.5 and publishing it, we will confirm that the target release includes the fix. I will keep the document body unchanged for now.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
first-time-contributorIndicates that the PR was contributed by an external member and is a first-time contributor.missing-translation-statusThis PR does not have translation status info.needs-cherry-pick-release-8.5Should cherry pick this PR to release-8.5 branch.size/LDenotes a PR that changes 100-499 lines, ignoring generated files.
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is changed, added, or deleted? (Required)
Document database-level read-only mode for migration cutover and data validation:
INFORMATION_SCHEMA.SCHEMATA_EXTENSIONSreference and query example.ALTER DATABASE,SHOW CREATE DATABASE, privilege descriptions, system-variable cross-references, and navigation entries.The release-8.5 documentation assumes that pingcap/tidb#73801 has been merged, including SQL restoration of sequences in read-only databases. The first release version remains a TODO for confirmation.
Validation: Markdown formatting, internal links, link anchors, new-page metadata, and
git diff --checkpassed.Which TiDB version(s) do your changes apply to? (Required)
Tips for choosing the affected version(s):
By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.
For details, see tips for choosing the affected versions.
What is the related PR or file link(s)?
AI agent involvement
Do your changes match any of the following descriptions?
Summary by CodeRabbit
READ ONLYoption forALTER DATABASE, its supported values, and examples for enabling read-only mode and restoring write access.INFORMATION_SCHEMA.SCHEMATA_EXTENSIONS, including its columns, database settings, and a query example, with navigation links to related pages.SHOW CREATE DATABASEoutput.