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

KVStore: Fix spurious region overlap when two region are both applying snapshots #9330

Merged
merged 19 commits into from
Aug 20, 2024

Conversation

CalvinNeo
Copy link
Member

@CalvinNeo CalvinNeo commented Aug 16, 2024

What problem does this PR solve?

Issue Number: close #9329

Problem Summary:

See the issue.

What is changed and how it works?

  1. Ask for proxy's region local state to determine whether regions are actually overlapping, if the overlapped regions are in Applying state.
  2. Clean only the range of new_region rather than old_region.

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

Fix spurious region overlap problem
修复虚假的 Region overlap 引起的 panic 问题

Signed-off-by: Calvin Neo <[email protected]>
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed do-not-merge/needs-triage-completed labels Aug 16, 2024
Comment on lines 225 to 227
dm_storage->deleteRange(new_key_range, context.getSettingsRef());
// We must flush the deletion to the disk here, because we only flush new range when persisting this region later.
dm_storage->flushCache(context, old_key_range, /*try_until_succeed*/ true);
dm_storage->flushCache(context, new_key_range, /*try_until_succeed*/ true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why here is changed to delete the new_key_range?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider:

  1. apply snapshot a of range [0..100)
  2. apply snapshot b of range [50..100)
  3. apply snapshot a' of range [0..50)

In 3, we could clean the old range [0..100), which covers the written data of snapshot b in stage 2

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we only need to delete the existing data on the new_range, then the following code of ingestFiles(..., /*clear_data_in_range=*/true, ...) can do it. We don't need this branch.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@CalvinNeo CalvinNeo changed the title KVStore: Fix spurious region overlap when two region are both applying snapshots WIP KVStore: Fix spurious region overlap when two region are both applying snapshots Aug 16, 2024
@ti-chi-bot ti-chi-bot bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 16, 2024
Signed-off-by: Calvin Neo <[email protected]>
Signed-off-by: Calvin Neo <[email protected]>
@CalvinNeo CalvinNeo changed the title WIP KVStore: Fix spurious region overlap when two region are both applying snapshots KVStore: Fix spurious region overlap when two region are both applying snapshots Aug 16, 2024
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 16, 2024
Signed-off-by: Calvin Neo <[email protected]>
@JaySon-Huang
Copy link
Contributor

JaySon-Huang commented Aug 19, 2024

Are these failed tests related to your changes?
https://do.pingcap.net/jenkins/blue/organizations/jenkins/pingcap%2Ftiflash%2Fpull_unit_test/detail/pull_unit_test/1258/pipeline

FAILED TESTS (3/2852):
    7123 ms: /tiflash/gtests_dbms RegionKVStoreTestFAP.FAPWorkerException
    2614 ms: /tiflash/gtests_dbms ByIngestUsingSplit/ApplySnapshotTest.WithNewRegionRange/0
    2657 ms: /tiflash/gtests_dbms ByIngestUsingSplit/ApplySnapshotTest.WithNewRegionRange/1

@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Aug 19, 2024
a
Signed-off-by: Calvin Neo <[email protected]>
Copy link
Contributor

@Lloyd-Pottiger Lloyd-Pottiger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Others lgtm

dbms/src/Storages/KVStore/MultiRaft/RegionRangeKeys.h Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Aug 19, 2024
@CalvinNeo
Copy link
Member Author

/hold

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 20, 2024
@CalvinNeo
Copy link
Member Author

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 20, 2024
Copy link
Contributor

@JaySon-Huang JaySon-Huang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest LGTM

dbms/src/Storages/KVStore/KVStore.h Outdated Show resolved Hide resolved
dbms/src/Storages/KVStore/MultiRaft/ApplySnapshot.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@JaySon-Huang JaySon-Huang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

ti-chi-bot bot commented Aug 20, 2024

[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 Aug 20, 2024
Copy link
Contributor

ti-chi-bot bot commented Aug 20, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-08-19 09:19:58.258556397 +0000 UTC m=+170793.393006516: ☑️ agreed by Lloyd-Pottiger.
  • 2024-08-20 06:57:12.751179727 +0000 UTC m=+248627.885629847: ☑️ agreed by JaySon-Huang.

@ti-chi-bot ti-chi-bot bot merged commit 5500b35 into pingcap:master Aug 20, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KVStore: spurious region overlap may happen when two region are both applying snapshots
3 participants