From fa5394fae0d562800f5c3c0c0ef2ce8a67d5b128 Mon Sep 17 00:00:00 2001 From: lidezhu <47731263+lidezhu@users.noreply.github.com> Date: Tue, 7 Jan 2025 12:09:41 +0800 Subject: [PATCH] schemastore: remove wrong version (#798) * add log * schemastore: remove unused version --- logservice/schemastore/multi_version.go | 12 +++++------- logservice/schemastore/persist_storage.go | 2 +- .../schemastore/persist_storage_ddl_handlers.go | 1 - pkg/common/table_info.go | 7 ++----- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/logservice/schemastore/multi_version.go b/logservice/schemastore/multi_version.go index e84bdb445..ab8a15e03 100644 --- a/logservice/schemastore/multi_version.go +++ b/logservice/schemastore/multi_version.go @@ -61,12 +61,11 @@ func newEmptyVersionedTableInfoStore(tableID int64) *versionedTableInfoStore { } } -func (v *versionedTableInfoStore) addInitialTableInfo(info *common.TableInfo) { +func (v *versionedTableInfoStore) addInitialTableInfo(info *common.TableInfo, version uint64) { v.mu.Lock() defer v.mu.Unlock() // assertEmpty(v.infos) - // log.Info("addInitialTableInfo", zap.Int64("tableID", int64(v.tableID)), zap.Uint64("version", info.Version)) - v.infos = append(v.infos, &tableInfoItem{version: uint64(info.Version), info: info}) + v.infos = append(v.infos, &tableInfoItem{version: version, info: info}) } func (v *versionedTableInfoStore) getTableID() int64 { @@ -160,7 +159,6 @@ func assertEmpty(infos []*tableInfoItem, event *PersistedDDLEvent) { log.Panic("shouldn't happen", zap.Any("infosLen", len(infos)), zap.Any("lastVersion", infos[len(infos)-1].version), - zap.Any("lastTableInfoVersion", infos[len(infos)-1].info.Version), zap.String("query", event.Query), zap.Int64("tableID", event.CurrentTableID), zap.Uint64("finishedTs", event.FinishedTs), @@ -225,11 +223,11 @@ func (v *versionedTableInfoStore) doApplyDDL(event *PersistedDDLEvent) { } tableInfo, deleted := handler.extractTableInfoFunc(event, v.tableID) if tableInfo != nil { - v.infos = append(v.infos, &tableInfoItem{version: uint64(event.FinishedTs), info: tableInfo}) + v.infos = append(v.infos, &tableInfoItem{version: event.FinishedTs, info: tableInfo}) if ddlType == model.ActionRecoverTable { - v.deleteVersion = uint64(math.MaxUint64) + v.deleteVersion = math.MaxUint64 } } else if deleted { - v.deleteVersion = uint64(event.FinishedTs) + v.deleteVersion = event.FinishedTs } } diff --git a/logservice/schemastore/persist_storage.go b/logservice/schemastore/persist_storage.go index bc9056c41..522a8b53b 100644 --- a/logservice/schemastore/persist_storage.go +++ b/logservice/schemastore/persist_storage.go @@ -499,7 +499,7 @@ func addTableInfoFromKVSnap( ) error { tableInfo := readTableInfoInKVSnap(snap, store.getTableID(), kvSnapVersion) if tableInfo != nil { - store.addInitialTableInfo(tableInfo) + store.addInitialTableInfo(tableInfo, kvSnapVersion) } return nil } diff --git a/logservice/schemastore/persist_storage_ddl_handlers.go b/logservice/schemastore/persist_storage_ddl_handlers.go index d560dd082..20a23d24a 100644 --- a/logservice/schemastore/persist_storage_ddl_handlers.go +++ b/logservice/schemastore/persist_storage_ddl_handlers.go @@ -1080,7 +1080,6 @@ func extractTableInfoFuncForExchangeTablePartition(event *PersistedDDLEvent, tab pmodel.NewCIStr(event.PrevTableName).O, tableID, false, - event.PreTableInfo.Version, columnSchema) return tableInfo, false } diff --git a/pkg/common/table_info.go b/pkg/common/table_info.go index 43bef1afe..c0e1ed743 100644 --- a/pkg/common/table_info.go +++ b/pkg/common/table_info.go @@ -281,8 +281,6 @@ type TableInfo struct { // So be careful when using the TableInfo. TableName TableName `json:"table-name"` - // Version means the version of the table info. - Version uint16 `json:"version"` columnSchema *columnSchema `json:"-"` preSQLs struct { @@ -574,7 +572,7 @@ func (ti *TableInfo) GetPrimaryKeyColumnNames() []string { return result } -func NewTableInfo(schemaID int64, schemaName string, tableName string, tableID int64, isPartition bool, version uint16, columnSchema *columnSchema) *TableInfo { +func NewTableInfo(schemaID int64, schemaName string, tableName string, tableID int64, isPartition bool, columnSchema *columnSchema) *TableInfo { ti := &TableInfo{ SchemaID: schemaID, TableName: TableName{ @@ -584,7 +582,6 @@ func NewTableInfo(schemaID int64, schemaName string, tableName string, tableID i IsPartition: isPartition, quotedName: QuoteSchema(schemaName, tableName), }, - Version: version, columnSchema: columnSchema, } @@ -603,7 +600,7 @@ func WrapTableInfo(schemaID int64, schemaName string, info *model.TableInfo) *Ta sharedColumnSchemaStorage := GetSharedColumnSchemaStorage() columnSchema := sharedColumnSchemaStorage.GetOrSetColumnSchema(info) - return NewTableInfo(schemaID, schemaName, info.Name.O, info.ID, info.GetPartitionInfo() != nil, info.Version, columnSchema) + return NewTableInfo(schemaID, schemaName, info.Name.O, info.ID, info.GetPartitionInfo() != nil, columnSchema) } // GetColumnDefaultValue returns the default definition of a column.