Skip to content

Commit 295de41

Browse files
committed
schema storage: remove schemaVersion in schema storage
1 parent 55bca14 commit 295de41

File tree

2 files changed

+5
-33
lines changed

2 files changed

+5
-33
lines changed

cdc/entry/schema/snapshot.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -109,24 +109,6 @@ func (s *Snapshot) FillSchemaName(job *timodel.Job) error {
109109
return nil
110110
}
111111

112-
// GetSchemaVersion returns the schema version of the meta.
113-
func GetSchemaVersion(meta timeta.Reader) (int64, error) {
114-
// After we get the schema version at startTs, if the diff corresponding to that version does not exist,
115-
// it means that the job is not committed yet, so we should subtract one from the version, i.e., version--.
116-
version, err := meta.GetSchemaVersion()
117-
if err != nil {
118-
return 0, errors.Trace(err)
119-
}
120-
diff, err := meta.GetSchemaDiff(version)
121-
if err != nil {
122-
return 0, errors.Trace(err)
123-
}
124-
if diff == nil {
125-
version--
126-
}
127-
return version, nil
128-
}
129-
130112
// NewSnapshotFromMeta creates a schema snapshot from meta.
131113
func NewSnapshotFromMeta(
132114
id model.ChangeFeedID,

cdc/entry/schema_storage.go

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@ type schemaStorage struct {
7373
snaps []*schema.Snapshot
7474
snapsMu sync.RWMutex
7575

76-
gcTs uint64
77-
resolvedTs uint64
78-
schemaVersion int64
76+
gcTs uint64
77+
resolvedTs uint64
7978

8079
filter filter.Filter
8180

@@ -92,9 +91,8 @@ func NewSchemaStorage(
9291
role util.Role, filter filter.Filter,
9392
) (SchemaStorage, error) {
9493
var (
95-
snap *schema.Snapshot
96-
version int64
97-
err error
94+
snap *schema.Snapshot
95+
err error
9896
)
9997
// storage may be nil in some unit test cases.
10098
if storage == nil {
@@ -105,7 +103,6 @@ func NewSchemaStorage(
105103
if err != nil {
106104
return nil, errors.Trace(err)
107105
}
108-
version, err = schema.GetSchemaVersion(meta)
109106
if err != nil {
110107
return nil, errors.Trace(err)
111108
}
@@ -116,7 +113,6 @@ func NewSchemaStorage(
116113
forceReplicate: forceReplicate,
117114
filter: filter,
118115
id: id,
119-
schemaVersion: version,
120116
role: role,
121117
}, nil
122118
}
@@ -194,7 +190,6 @@ func (s *schemaStorage) GetLastSnapshot() *schema.Snapshot {
194190
// HandleDDLJob creates a new snapshot in storage and handles the ddl job
195191
func (s *schemaStorage) HandleDDLJob(job *timodel.Job) error {
196192
if s.skipJob(job) {
197-
s.schemaVersion = job.BinlogInfo.SchemaVersion
198193
s.AdvanceResolvedTs(job.BinlogInfo.FinishedTS)
199194
return nil
200195
}
@@ -203,16 +198,13 @@ func (s *schemaStorage) HandleDDLJob(job *timodel.Job) error {
203198
var snap *schema.Snapshot
204199
if len(s.snaps) > 0 {
205200
lastSnap := s.snaps[len(s.snaps)-1]
206-
// We use schemaVersion to check if an already-executed DDL job is processed for a second time.
207-
// Unexecuted DDL jobs should have largest schemaVersions.
208-
if job.BinlogInfo.FinishedTS <= lastSnap.CurrentTs() || job.BinlogInfo.SchemaVersion <= s.schemaVersion {
201+
if job.BinlogInfo.FinishedTS <= lastSnap.CurrentTs() {
209202
log.Info("schemaStorage: ignore foregone DDL",
210203
zap.String("namespace", s.id.Namespace),
211204
zap.String("changefeed", s.id.ID),
212205
zap.String("DDL", job.Query),
213206
zap.Int64("jobID", job.ID),
214207
zap.Uint64("finishTs", job.BinlogInfo.FinishedTS),
215-
zap.Int64("schemaVersion", s.schemaVersion),
216208
zap.Int64("jobSchemaVersion", job.BinlogInfo.SchemaVersion),
217209
zap.String("role", s.role.String()))
218210
return nil
@@ -234,7 +226,6 @@ func (s *schemaStorage) HandleDDLJob(job *timodel.Job) error {
234226
return errors.Trace(err)
235227
}
236228
s.snaps = append(s.snaps, snap)
237-
s.schemaVersion = job.BinlogInfo.SchemaVersion
238229
s.AdvanceResolvedTs(job.BinlogInfo.FinishedTS)
239230
log.Info("schemaStorage: update snapshot by the DDL job",
240231
zap.String("namespace", s.id.Namespace),
@@ -243,7 +234,6 @@ func (s *schemaStorage) HandleDDLJob(job *timodel.Job) error {
243234
zap.String("table", job.TableName),
244235
zap.String("query", job.Query),
245236
zap.Uint64("finishedTs", job.BinlogInfo.FinishedTS),
246-
zap.Uint64("schemaVersion", uint64(s.schemaVersion)),
247237
zap.String("role", s.role.String()))
248238
return nil
249239
}

0 commit comments

Comments
 (0)