Skip to content

Commit

Permalink
fix refresh table entry invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
GroundWu committed Jun 13, 2024
1 parent 9921873 commit 491beeb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
35 changes: 28 additions & 7 deletions route/route_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,13 +440,34 @@ func (i *ObRouteInfo) refreshTableLocations(addr *tcpAddr) error {
i.tableLocations.Range(func(key, value interface{}) bool {
tableName := key.(string)
entry := value.(*ObTableEntry)
for _, replica := range entry.tableLocation.replicaLocations {
if replica.addr.tcpAddr.Equal(addr) {
// trigger refresh table
isRefreshing := &atomic.Bool{}
isRefreshing.Store(false)
i.taskInfo.tables.AddIfAbsent(tableName, isRefreshing)
i.taskInfo.TriggerRefreshTable()
if !entry.IsPartitionTable() {
for _, replica := range entry.tableLocation.replicaLocations {
if replica.addr.tcpAddr.Equal(addr) {
// trigger refresh table
isRefreshing := &atomic.Bool{}
isRefreshing.Store(false)
i.taskInfo.tables.AddIfAbsent(tableName, isRefreshing)
i.taskInfo.TriggerRefreshTable()
}
}
} else {
for partId, partLocation := range entry.partLocationEntry.partLocations {
if partLocation != nil {
replica := partLocation.getReplica(ConsistencyStrong)
if replica != nil && replica.addr.tcpAddr.Equal(addr) {
// trigger refresh table
isRefreshing := &atomic.Bool{}
isRefreshing.Store(false)
i.taskInfo.tables.AddIfAbsent(tableName, isRefreshing)
i.taskInfo.TriggerRefreshTable()
} else if replica == nil {
log.Warn("Routine", nil, "partLocation leader replica is nil",
log.String("tableName", tableName), log.Uint64("partId", partId))
}
} else {
log.Warn("Routine", nil, "partLocation is nil",
log.String("tableName", tableName), log.Uint64("partId", partId))
}
}
}
return true
Expand Down
2 changes: 1 addition & 1 deletion route/table_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type ObTableEntry struct {
refreshTime time.Time // last refresh time
tableEntryKey *ObTableEntryKey // clusterName/tenantName/databaseName/tableName
partitionInfo *obPartitionInfo // partition key meta info
tableLocation *ObTableLocation // location of table, all replica information of table
tableLocation *ObTableLocation // all replica location for non-partition table
partLocationEntry *ObPartLocationEntry // all partition location of table
}

Expand Down

0 comments on commit 491beeb

Please sign in to comment.