Skip to content

Commit

Permalink
schemastore: remove wrong version (#798)
Browse files Browse the repository at this point in the history
* add log

* schemastore: remove unused version
  • Loading branch information
lidezhu authored Jan 7, 2025
1 parent a1a38ba commit fa5394f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
12 changes: 5 additions & 7 deletions logservice/schemastore/multi_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
}
}
2 changes: 1 addition & 1 deletion logservice/schemastore/persist_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 0 additions & 1 deletion logservice/schemastore/persist_storage_ddl_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,6 @@ func extractTableInfoFuncForExchangeTablePartition(event *PersistedDDLEvent, tab
pmodel.NewCIStr(event.PrevTableName).O,
tableID,
false,
event.PreTableInfo.Version,
columnSchema)
return tableInfo, false
}
Expand Down
7 changes: 2 additions & 5 deletions pkg/common/table_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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{
Expand All @@ -584,7 +582,6 @@ func NewTableInfo(schemaID int64, schemaName string, tableName string, tableID i
IsPartition: isPartition,
quotedName: QuoteSchema(schemaName, tableName),
},
Version: version,
columnSchema: columnSchema,
}

Expand All @@ -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.
Expand Down

0 comments on commit fa5394f

Please sign in to comment.