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

ddl: Fix corner case of FLASHBACK DATABASE (#8536) #8538

Merged

Conversation

ti-chi-bot
Copy link
Member

@ti-chi-bot ti-chi-bot commented Dec 18, 2023

This is an automated cherry-pick of #8536

What problem does this PR solve?

Issue Number: close #8506

Problem Summary:

If the Region snapshot arrived TiFlash after the database has been dropped, then we can not successfully create the Storage instance because we can not fetch the DatabaseInfo from TiKV. And also DatabaseInfo can not be fetch by "mvcc get".

if (storage == nullptr)
{
auto db_info = getter.getDatabase(database_id);
if (db_info == nullptr)
{
LOG_ERROR(log, "database is not exist in TiKV, applyTable need retry, database_id={}", database_id);
return false;
}
// Create the instance with the latest table info
// If the table info is get by mvcc, it means the table is actually in "dropped" status
applyCreateStorageInstance(db_info, table_info, get_by_mvcc);

What is changed and how it works?

To successfully create a Storage instance (applyCreateStorageInstance), we don't need the DatabaseInfo, a DatabaseID is sufficient. We are rewriting methods in SchemaBuilder to replace the methods with DatabaseInfo by DatabaseID. So that we can create those Storage instances and decode the Raft logs or snapshots after a database is dropped and the data can be "flashback" later.
What's more, avoiding fetching the DatabaseInfo from TiKV can speed up syncing schema.

For those methods that need the DatabaseInfo to get the database name in TiDB to rename tables, we fetch the DatabaseInfo from the local cache because the applyDiff that calls those methods should be applied before the "drop database" SchemaDiff.

Add a failpoint to pause pre-handling snapshot for testing.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. type/cherry-pick-for-release-7.5 This PR is cherry-picked to release-7.5 from a source PR. labels Dec 18, 2023
@JaySon-Huang
Copy link
Contributor

/run-all-tests

1 similar comment
@JaySon-Huang
Copy link
Contributor

/run-all-tests

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Dec 18, 2023
@ti-chi-bot ti-chi-bot added the cherry-pick-approved Cherry pick PR approved by release team. label Dec 18, 2023
Copy link
Contributor

ti-chi-bot bot commented Dec 18, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JaySon-Huang, Lloyd-Pottiger

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [JaySon-Huang,Lloyd-Pottiger]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 18, 2023
Copy link
Contributor

ti-chi-bot bot commented Dec 18, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-12-18 06:38:58.439845928 +0000 UTC m=+856629.477072850: ☑️ agreed by JaySon-Huang.
  • 2023-12-18 07:17:18.606831373 +0000 UTC m=+858929.644058300: ☑️ agreed by Lloyd-Pottiger.

@ti-chi-bot ti-chi-bot bot merged commit ac988a9 into pingcap:release-7.5 Dec 18, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved cherry-pick-approved Cherry pick PR approved by release team. lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. type/cherry-pick-for-release-7.5 This PR is cherry-picked to release-7.5 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants