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

fix transfer page bornts #17729

Merged
merged 9 commits into from
Jul 26, 2024
Merged
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
11 changes: 10 additions & 1 deletion pkg/vm/engine/tae/tables/txnentries/flushTableTail.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,15 @@ func (entry *flushTableTailEntry) addTransferPages(ctx context.Context) {
pages := make([]*model.TransferHashPage, 0, len(entry.transMappings.Mappings))
var duration time.Duration
var start time.Time
bts := time.Now().Add(time.Hour)
for i, mcontainer := range entry.transMappings.Mappings {
m := mcontainer.M
if len(m) == 0 {
continue
}
id := entry.ablksHandles[i].Fingerprint()
entry.pageIds = append(entry.pageIds, id)
page := model.NewTransferHashPage(id, time.Now(), isTransient, entry.rt.LocalFs.Service, model.GetTTL(), model.GetDiskTTL())
page := model.NewTransferHashPage(id, bts, isTransient, entry.rt.LocalFs.Service, model.GetTTL(), model.GetDiskTTL())
mapping := make(map[uint32][]byte, len(m))
for srcRow, dst := range m {
blkid := objectio.NewBlockidWithObjectID(entry.createdBlkHandles.GetID(), uint16(dst.BlkIdx))
Expand All @@ -158,6 +159,14 @@ func (entry *flushTableTailEntry) addTransferPages(ctx context.Context) {

start = time.Now()
model.WriteTransferPage(ctx, entry.rt.LocalFs.Service, pages, *ioVector)
now := time.Now()
for _, page := range pages {
if page.BornTS() != bts {
page.SetBornTS(now.Add(time.Minute))
} else {
page.SetBornTS(now)
}
}
duration += time.Since(start)
v2.TransferPageFlushLatencyHistogram.Observe(duration.Seconds())
}
Expand Down
19 changes: 17 additions & 2 deletions pkg/vm/engine/tae/tables/txnentries/mergeobjects.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ func NewMergeObjectsEntry(

func (entry *mergeObjectsEntry) prepareTransferPage(ctx context.Context) {
k := 0
pagesToSet := make([][]*model.TransferHashPage, 0, len(entry.droppedObjs))
bts := time.Now().Add(time.Hour)
for _, obj := range entry.droppedObjs {
ioVector := model.InitTransferPageIO()
pages := make([]*model.TransferHashPage, 0, obj.BlockCnt())
Expand All @@ -111,7 +113,7 @@ func (entry *mergeObjectsEntry) prepareTransferPage(ctx context.Context) {
isTransient := !tblEntry.GetLastestSchema().HasPK()
id := obj.AsCommonID()
id.SetBlockOffset(uint16(j))
page := model.NewTransferHashPage(id, time.Now(), isTransient, entry.rt.LocalFs.Service, model.GetTTL(), model.GetDiskTTL())
page := model.NewTransferHashPage(id, bts, isTransient, entry.rt.LocalFs.Service, model.GetTTL(), model.GetDiskTTL())
mapping := make(map[uint32][]byte, len(m))
for srcRow, dst := range m {
objID := entry.createdObjs[dst.ObjIdx].ID()
Expand All @@ -129,15 +131,28 @@ func (entry *mergeObjectsEntry) prepareTransferPage(ctx context.Context) {
duration += time.Since(start)

entry.pageIds = append(entry.pageIds, id)
_ = entry.rt.TransferTable.AddPage(page)
entry.rt.TransferTable.AddPage(page)
pages = append(pages, page)
}

start = time.Now()
model.WriteTransferPage(ctx, entry.rt.LocalFs.Service, pages, *ioVector)
pagesToSet = append(pagesToSet, pages)
duration += time.Since(start)
v2.TransferPageMergeLatencyHistogram.Observe(duration.Seconds())
}

now := time.Now()
for _, pages := range pagesToSet {
for _, page := range pages {
if page.BornTS() != bts {
page.SetBornTS(now.Add(time.Minute))
} else {
page.SetBornTS(now)
}
}
}

if k != len(entry.transMappings) {
logutil.Fatal(fmt.Sprintf("k %v, mapping %v", k, len(entry.transMappings)))
}
Expand Down
Loading