Skip to content

Conversation

@marsishandsome
Copy link
Collaborator

@marsishandsome marsishandsome commented Jul 14, 2021

What problem does this PR solve?

This is a subtask of tikv/tikv#10563.

What is changed and how it works?

TiKV java client support Bulk Load using the ingest API.

  • support RawKV Region Split
  • support switch TiKV to import mode
  • support rawWrite API to ingest data

this PR depends on:

Check List

Tests

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

Code changes

  • Has exported function/method change
  • Has exported variable/fields change
  • Has interface methods change
  • Has persistent data change

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation
  • Need to be included in the release note

@marsishandsome marsishandsome force-pushed the feature/support-rawkv-import branch 5 times, most recently from fd126c5 to e03b641 Compare July 14, 2021 05:49
@marsishandsome marsishandsome force-pushed the feature/support-rawkv-import branch 17 times, most recently from a43e7e2 to 6ec7e09 Compare July 19, 2021 08:24
@marsishandsome
Copy link
Collaborator Author

/run-all-tests tikv=pr/10524

1 similar comment
@marsishandsome
Copy link
Collaborator Author

/run-all-tests tikv=pr/10524

@marsishandsome marsishandsome force-pushed the feature/support-rawkv-import branch 4 times, most recently from fca1963 to 3dc1da2 Compare July 20, 2021 07:13
@marsishandsome marsishandsome changed the title [WIP] RawKV support SST Ingest using KVStream interface RawKV support SST Ingest using KVStream interface Jul 20, 2021
@marsishandsome marsishandsome force-pushed the feature/support-rawkv-import branch from 3dc1da2 to 7b47468 Compare July 20, 2021 07:34
@marsishandsome marsishandsome requested review from Little-Wallace, andylokandy and birdstorm and removed request for birdstorm July 20, 2021 07:35
@marsishandsome marsishandsome force-pushed the feature/support-rawkv-import branch from 7b47468 to a24b2ed Compare July 20, 2021 07:40
return splitRegion(splitKeys, backOffer, 1);
}

private List<Metapb.Region> splitRegion(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why use recursive function to retry rather than a loop?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's not a simple retry, e.g.

  • we need to split 6 keys
  • 2 keys are split successfully, 4 keys are failed
  • retry to split the 4 failed keys

It's easy to use a recursive function to implement this logic.

Comment on lines +58 to +65
public void keepTiKVToImportMode() {
ingestScheduledExecutorService.scheduleAtFixedRate(
this::switchTiKVToImportMode, 0, KEEP_TIKV_TO_IMPORT_MODE_PERIOD, TimeUnit.SECONDS);
}

public void stopKeepTiKVToImportMode() {
ingestScheduledExecutorService.shutdown();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's better to keep this two function private and be called automatically by switchTiKVToXXXMode()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

switchTiKVToNormalMode is called one time, while keepTiKVToImportMode will start a scheduler and call switchTiKVToImportMode every 2 minute.

The name keepTiKVToImportMode is used in order that

  • let users know that a scheduler will be started after calling keepTiKVToImportMode
  • stopKeepTiKVToImportMode must be called to stop the scheduler

Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need to call keep import repeatedly?

Copy link
Contributor

Choose a reason for hiding this comment

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

Because I presumed that there will be multiple import clients. But now I know that the API is for example purpose.

returnNumber = 0;
for (ImporterStoreClient client : clientList) {
if (client.isRawWriteResponseReceived()) {
returnNumber++;
Copy link
Contributor

Choose a reason for hiding this comment

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

the client is not removed from clientList, will it count twice in the next iteration?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

refactor this code, PTAL


private void ingest() throws GrpcException {
int returnNumber = 0;
while (returnNumber < clientList.size()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this dead loop if a client never succeed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

then will go to client.hasRawWriteResponseError() and throw new GrpcException

@marsishandsome marsishandsome force-pushed the feature/support-rawkv-import branch 2 times, most recently from bdba26f to 40686fc Compare July 20, 2021 09:59
@tikv tikv deleted a comment from andylokandy Jul 21, 2021
@marsishandsome
Copy link
Collaborator Author

@andylokandy PTAL

@marsishandsome marsishandsome requested a review from birdstorm July 22, 2021 02:10
Signed-off-by: marsishandsome <marsishandsome@gmail.com>
Signed-off-by: marsishandsome <marsishandsome@gmail.com>
Signed-off-by: marsishandsome <marsishandsome@gmail.com>
Signed-off-by: marsishandsome <marsishandsome@gmail.com>
@marsishandsome marsishandsome force-pushed the feature/support-rawkv-import branch from 356fa69 to eecb406 Compare July 22, 2021 02:16
Signed-off-by: marsishandsome <marsishandsome@gmail.com>
@marsishandsome marsishandsome force-pushed the feature/support-rawkv-import branch from eecb406 to 4945902 Compare July 22, 2021 02:17
Signed-off-by: marsishandsome <marsishandsome@gmail.com>
@marsishandsome
Copy link
Collaborator Author

/run-all-tests

Copy link
Collaborator

@birdstorm birdstorm left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants