@@ -4,8 +4,10 @@ package streamhelper
4
4
5
5
import (
6
6
"context"
7
+ "math"
7
8
"time"
8
9
10
+ "github.com/pingcap/errors"
9
11
logbackup "github.com/pingcap/kvproto/pkg/logbackuppb"
10
12
"github.com/pingcap/tidb/br/pkg/utils"
11
13
"github.com/pingcap/tidb/pkg/config"
@@ -46,7 +48,21 @@ type PDRegionScanner struct {
46
48
// Returns the minimal service GC safe point across all services.
47
49
// If the arguments is `0`, this would remove the service safe point.
48
50
func (c PDRegionScanner ) BlockGCUntil (ctx context.Context , at uint64 ) (uint64 , error ) {
49
- return c .UpdateServiceGCSafePoint (ctx , logBackupServiceID , int64 (logBackupSafePointTTL .Seconds ()), at )
51
+ minimalSafePoint , err := c .UpdateServiceGCSafePoint (
52
+ ctx , logBackupServiceID , int64 (logBackupSafePointTTL .Seconds ()), at )
53
+ if err != nil {
54
+ return 0 , errors .Annotate (err , "failed to block gc until" )
55
+ }
56
+ if minimalSafePoint > at {
57
+ return 0 , errors .Errorf ("minimal safe point %d is greater than the target %d" , minimalSafePoint , at )
58
+ }
59
+ return at , nil
60
+ }
61
+
62
+ func (c PDRegionScanner ) UnblockGC (ctx context.Context ) error {
63
+ // set ttl to 0, means remove the safe point.
64
+ _ , err := c .UpdateServiceGCSafePoint (ctx , logBackupServiceID , 0 , math .MaxUint64 )
65
+ return err
50
66
}
51
67
52
68
// TODO: It should be able to synchoronize the current TS with the PD.
0 commit comments