Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#58963
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
Tristan1900 authored and ti-chi-bot committed Jan 21, 2025
1 parent 80edd4e commit eefe1cb
Show file tree
Hide file tree
Showing 4 changed files with 683 additions and 1 deletion.
5 changes: 5 additions & 0 deletions br/pkg/restore/log_client/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ go_test(
"//br/pkg/gluetidb",
"//br/pkg/mock",
"//br/pkg/restore/internal/import_client",
"//br/pkg/restore/internal/rawkv",
"//br/pkg/restore/split",
"//br/pkg/restore/utils",
"//br/pkg/storage",
Expand Down Expand Up @@ -122,7 +123,11 @@ go_test(
"@com_github_pingcap_kvproto//pkg/pdpb",
"@com_github_pingcap_log//:log",
"@com_github_stretchr_testify//require",
<<<<<<< HEAD
"@com_github_tikv_pd_client//:client",
=======
"@com_github_tikv_client_go_v2//rawkv",
>>>>>>> 3a378c8e384 (br: add retry for raw kv client put (#58963))
"@org_golang_google_grpc//codes",
"@org_golang_google_grpc//keepalive",
"@org_golang_google_grpc//status",
Expand Down
13 changes: 12 additions & 1 deletion br/pkg/restore/log_client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ func (rc *LogClient) restoreMetaKvEntries(
failpoint.Inject("failed-to-restore-metakv", func(_ failpoint.Value) {
failpoint.Return(0, 0, errors.Errorf("failpoint: failed to restore metakv"))
})
if err := rc.rawKVClient.Put(ctx, newEntry.Key, newEntry.Value, entry.Ts); err != nil {
if err := PutRawKvWithRetry(ctx, rc.rawKVClient, newEntry.Key, newEntry.Value, entry.Ts); err != nil {
return 0, 0, errors.Trace(err)
}
// for failpoint, we need to flush the cache in rawKVClient every time
Expand Down Expand Up @@ -1717,6 +1717,7 @@ func (rc *LogClient) FailpointDoChecksumForLogRestore(
return eg.Wait()
}

<<<<<<< HEAD
type LogFilesIterWithSplitHelper struct {
iter LogIter
helper *logsplit.LogSplitHelper
Expand Down Expand Up @@ -1764,4 +1765,14 @@ func (splitIter *LogFilesIterWithSplitHelper) TryNext(ctx context.Context) iter.
res := iter.Emit(splitIter.buffer[splitIter.next])
splitIter.next += 1
return res
=======
func PutRawKvWithRetry(ctx context.Context, client *rawkv.RawKVBatchClient, key, value []byte, originTs uint64) error {
err := utils.WithRetry(ctx, func() error {
return client.Put(ctx, key, value, originTs)
}, utils.NewRawClientBackoffStrategy())
if err != nil {
return errors.Errorf("failed to put raw kv after retry")
}
return nil
>>>>>>> 3a378c8e384 (br: add retry for raw kv client put (#58963))
}
Loading

0 comments on commit eefe1cb

Please sign in to comment.