Skip to content

Commit

Permalink
Merge branch 'release-4.0' into cherry-pick-3540-to-release-4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Nov 23, 2021
2 parents c8337bd + 248a2c0 commit 4016739
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
8 changes: 5 additions & 3 deletions cdc/owner/gc_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ func (m *gcManager) updateGCSafePoint(ctx cdcContext.Context, state *model.Globa
default:
continue
}
checkpointTs := cfState.Info.GetCheckpointTs(cfState.Status)
if minCheckpointTs > checkpointTs {
minCheckpointTs = checkpointTs
// When the changefeed starts up, CDC will do a snapshot read at (checkpoint-ts - 1) from TiKV,
// so (checkpoint - 1) should be an upper bound for the GC safepoint.
gcSafepointUpperBound := cfState.Info.GetCheckpointTs(cfState.Status) - 1
if minCheckpointTs > gcSafepointUpperBound {
minCheckpointTs = gcSafepointUpperBound
}
}
m.lastUpdatedTime = time.Now()
Expand Down
2 changes: 1 addition & 1 deletion cdc/owner/gc_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (s *gcManagerSuite) TestUpdateGCSafePoint(c *check.C) {
mockPDClient.updateServiceGCSafePointFunc = func(ctx context.Context, serviceID string, ttl int64, safePoint uint64) (uint64, error) {
c.Assert(serviceID, check.Equals, cdcServiceSafePointID)
c.Assert(ttl, check.Equals, gcManager.gcTTL)
c.Assert(safePoint, check.Equals, uint64(20))
c.Assert(safePoint, check.Equals, uint64(19))
return 0, nil
}
err = gcManager.updateGCSafePoint(ctx, state)
Expand Down
6 changes: 6 additions & 0 deletions tests/gc_safepoint/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ function clear_gc_worker_safepoint() {
ETCDCTL_API=3 etcdctl --endpoints=$pd_addr del /pd/$pd_cluster_id/gc/safe_point/service/ticdc
}

function clear_gc_worker_safepoint() {
pd_addr=$1
pd_cluster_id=$2
ETCDCTL_API=3 etcdctl --endpoints=$pd_addr del /pd/$pd_cluster_id/gc/safe_point/service/ticdc
}

function check_safepoint_cleared() {
pd_addr=$1
pd_cluster_id=$2
Expand Down

0 comments on commit 4016739

Please sign in to comment.