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

FAP: Support cancel FAP tasks #8458

Merged
merged 89 commits into from
Jan 11, 2024
Merged

FAP: Support cancel FAP tasks #8458

merged 89 commits into from
Jan 11, 2024

Conversation

CalvinNeo
Copy link
Member

@CalvinNeo CalvinNeo commented Dec 4, 2023

What problem does this PR solve?

Issue Number: close #8382

Problem Summary:

  1. Support cancel FAP tasks
  2. Fix empty segments
  3. Fix the problem when restart with another regular snapshot after FAP has totally failed
  4. Fix maybe throw when build fap snapshot
  5. Fix test framework
  6. Fix snapshot in proxy when there is not CachedRegionInfo

What is changed and how it works?

RELATED PROXY PR: pingcap/tidb-engine-ext#363

FAP phase 1 can be canceled in:

  1. FastAddPeer when timeout
    It this happens, FastAddPeer will block wait FastAddPeerImpl to finish all cleaning work, and then return to Proxy. Otherwise, a later legacy snapshot may meet a cleaning FAP phase1 task.

It can't be canceled elsewhere in TiFlash, since once the task is canceled, it is not accessible from AsyncTasks. Then a FastAddPeer will create a new task for this.

It can't be canceled from Proxy, since it involves many modifications in Proxy.

It can't be canceled by a legacy snapshot, since the only way a legacy snapshot is trigger is that the FAP is finished or fallback so it can continue to receive MsgSnapshot.

It can't be canceled by a destroy peer event, since we don't handle MsgAppend in FAP phase 1 either. If there are some corner cases, then it can:

  1. Better be handled in proxy's side, in order to stop the FAP process.
  2. Better not be handled in FastAddPeer, before polling FAP status, check if the region is still exists. Because the region is likely not exist at the FAP phase 1 stage.

FAP phase 1 result can be cleaned in:

  1. FastAddPeerImpl when received cancel signal from FastAddPeer
  2. handleDestroy
  3. prehandleSnapshot

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

Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
@CalvinNeo
Copy link
Member Author

/hold for proxy

@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Dec 4, 2023
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
@CalvinNeo
Copy link
Member Author

/run-all-tests

Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
@@ -333,6 +333,12 @@ void KVStore::handleDestroy(UInt64 region_id, TMTContext & tmt)
void KVStore::handleDestroy(UInt64 region_id, TMTContext & tmt, const KVStoreTaskLock & task_lock)
{
const auto region = getRegion(region_id);
if (tmt.getContext().getSharedContextDisagg()->isDisaggregatedStorageMode())
Copy link
Member Author

Choose a reason for hiding this comment

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

Ensure the FAP tasks being cleaned before apply legacy snapshot

Copy link
Contributor

Choose a reason for hiding this comment

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

Is moving these lines to the beginning of this function to handle some corner cases? Maybe add some comment about it.

if (cancel_handle->blockedWaitFor(std::chrono::milliseconds(1000)))
{
LOG_INFO(log, "Cancel FAP during peer selecting, region_id={}", region_id);
// Just remove the task from AsyncTasks, it will not write anything in disk during this stage.
Copy link
Member Author

Choose a reason for hiding this comment

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

Because the task in select stage won't write anything to disk

@CalvinNeo
Copy link
Member Author

/run-all-tests

z
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
@CalvinNeo
Copy link
Member Author

/run-all-tests

@CalvinNeo
Copy link
Member Author

/run-unit-test

Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
@CalvinNeo
Copy link
Member Author

/run-integration-test

@JaySon-Huang
Copy link
Contributor

/run-unit-test

Copy link
Contributor

ti-chi-bot bot commented Jan 8, 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

Copy link
Contributor

ti-chi-bot bot commented Jan 8, 2024

[LGTM Timeline notifier]

Timeline:

  • 2023-12-07 06:35:38.212187049 +0000 UTC m=+1682166.877413229: ☑️ agreed by Lloyd-Pottiger.
  • 2024-01-08 03:28:09.921715548 +0000 UTC m=+241079.505969232: ☑️ agreed by JaySon-Huang.

Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
@CalvinNeo
Copy link
Member Author

image
image

CalvinNeo and others added 6 commits January 8, 2024 16:09
z
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
@CalvinNeo
Copy link
Member Author

/run-all-tests

@CalvinNeo
Copy link
Member Author

/run-unit-test

@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 Jan 11, 2024
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
@CalvinNeo
Copy link
Member Author

/run-all-tests

Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
@CalvinNeo
Copy link
Member Author

/run-all-tests

@ti-chi-bot ti-chi-bot bot merged commit 7779b00 into pingcap:master Jan 11, 2024
6 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-none size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce two stages FAP
4 participants