Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] for hack #1174

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
31 changes: 27 additions & 4 deletions logservice/schemastore/disk_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"encoding/json"
"math"
"strings"
"sync"
"time"

"github.com/cockroachdb/pebble"
Expand Down Expand Up @@ -709,22 +710,44 @@ func cleanObsoleteData(db *pebble.DB, oldGcTs uint64, gcTs uint64) {
}
}

var mutexForHack sync.Mutex
var tableInfoMapForHack = map[uint64]map[int64]*model.TableInfo{}
var tableMapForHack = map[uint64]map[int64]*BasicTableInfo{}
var partitionMapForHack = map[uint64]map[int64]BasicPartitionInfo{}

func loadAllPhysicalTablesAtTs(
storageSnap *pebble.Snapshot,
gcTs uint64,
snapVersion uint64,
tableFilter filter.Filter,
) ([]commonEvent.Table, error) {
// TODO: respect tableFilter(filter table in kv snap is easy, filter ddl jobs need more attention)
var tableInfoMap map[int64]*model.TableInfo
var tableMap map[int64]*BasicTableInfo
var partitionMap map[int64]BasicPartitionInfo

databaseMap, err := loadDatabasesInKVSnap(storageSnap, gcTs)
if err != nil {
return nil, err
}

tableInfoMap, tableMap, partitionMap, err := loadFullTablesInKVSnap(storageSnap, gcTs, databaseMap)
if err != nil {
return nil, err
mutexForHack.Lock()
if tableInfoMapForHack[gcTs] != nil {
tableInfoMap = tableInfoMapForHack[gcTs]
tableMap = tableMapForHack[gcTs]
partitionMap = partitionMapForHack[gcTs]
mutexForHack.Unlock()
} else {
mutexForHack.Unlock()
// TODO: respect tableFilter(filter table in kv snap is easy, filter ddl jobs need more attention)
tableInfoMap, tableMap, partitionMap, err = loadFullTablesInKVSnap(storageSnap, gcTs, databaseMap)
if err != nil {
return nil, err
}
tableInfoMapForHack[gcTs] = tableInfoMap
tableMapForHack[gcTs] = tableMap
partitionMapForHack[gcTs] = partitionMap
}

log.Info("after load tables in kv snap",
zap.Int("tableInfoMapLen", len(tableInfoMap)),
zap.Int("tableMapLen", len(tableMap)),
Expand Down
1 change: 1 addition & 0 deletions logservice/schemastore/persist_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ func (p *persistentStorage) getAllPhysicalTables(snapTs uint64, tableFilter filt
log.Debug("getAllPhysicalTables finish",
zap.Any("duration(s)", time.Since(start).Seconds()))
}()

return loadAllPhysicalTablesAtTs(storageSnap, gcTs, snapTs, tableFilter)
}

Expand Down