Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

cdclog: fix the lost ddl files (#1094) #1313

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/restore/log_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ func (l *LogClient) NeedRestoreDDL(fileName string) (bool, error) {
// maxUint64 - the first DDL event's commit ts as the file name to return the latest ddl file.
// see details at https://github.com/pingcap/ticdc/pull/826/files#diff-d2e98b3ed211b7b9bb7b6da63dd48758R81
ts = maxUint64 - ts
if l.maybeTSInRange(ts) {

// In cdc, we choose the first event as the file name of DDL file.
// so if the file ts is large than endTS, we can skip to execute it.
// FIXME find a unified logic to filter row changes files and ddl files.
if ts <= l.endTS {
return true, nil
}
log.Info("filter ddl file by ts", zap.String("name", fileName), zap.Uint64("ts", ts))
Expand Down
31 changes: 30 additions & 1 deletion pkg/restore/log_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (s *testLogRestoreSuite) TestTsInRange(c *C) {
}

// format cdclog will collect, because file sink will generate cdclog for streaming write.
ddlFile := "ddl.1"
ddlFile := "ddl.18446744073709551615"
collected, err = s.client.NeedRestoreDDL(ddlFile)
c.Assert(err, IsNil)
c.Assert(collected, IsTrue)
Expand All @@ -95,4 +95,33 @@ func (s *testLogRestoreSuite) TestTsInRange(c *C) {
c.Assert(err, IsNil)
c.Assert(collected, IsFalse)
}

s.client.ResetTSRange(424839867765096449, 424839886560821249)
// ddl suffix records the first event's commit ts

// the file name include the end ts, collect it.(maxUint64 - 424839886560821249)
ddlFile = "ddl.18021904187148730366"
collected, err = s.client.NeedRestoreDDL(ddlFile)
c.Assert(err, IsNil)
c.Assert(collected, IsTrue)

// the file name include the start ts, collect it.(maxUint64 - 424839867765096449)
ddlFile = "ddl.18021904205944455166"
collected, err = s.client.NeedRestoreDDL(ddlFile)
c.Assert(err, IsNil)
c.Assert(collected, IsTrue)

// the file first event's ts is smaller than the start ts, collect it.
// because we only know this file's first event not in TSRange.
// FIXME find a unified logic for collection.
ddlFile = "ddl.18021904205944455167"
collected, err = s.client.NeedRestoreDDL(ddlFile)
c.Assert(err, IsNil)
c.Assert(collected, IsTrue)

// the file first event's ts is large than end ts, skip it.
ddlFile = "ddl.18021904187148730365"
collected, err = s.client.NeedRestoreDDL(ddlFile)
c.Assert(err, IsNil)
c.Assert(collected, IsFalse)
}