e3: reconst MakeSteps - to check that files are indexed (#789)

This commit is contained in:
Alex Sharov 2022-12-19 10:26:43 +07:00 committed by GitHub
parent 2cabdd37fc
commit f239b04a72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 4 deletions

View File

@ -1293,7 +1293,16 @@ type AggregatorStep struct {
}
func (a *Aggregator22) MakeSteps() []*AggregatorStep {
accountSteps := a.accounts.MakeSteps()
to := a.maxTxNum.Load()
indexedMax := cmp.Min(
cmp.Min(a.accounts.endIndexedTxNumMinimax(), a.storage.endIndexedTxNumMinimax()),
a.code.endIndexedTxNumMinimax(),
)
if to != indexedMax {
log.Warn("[snapshots] not all files are indexed", "files", to/a.aggregationStep, "indexed", indexedMax/a.aggregationStep)
to = cmp.Min(to, indexedMax)
}
accountSteps := a.accounts.MakeSteps(to)
steps := make([]*AggregatorStep, len(accountSteps))
for i, accountStep := range accountSteps {
steps[i] = &AggregatorStep{
@ -1301,11 +1310,11 @@ func (a *Aggregator22) MakeSteps() []*AggregatorStep {
accounts: accountStep,
}
}
storageSteps := a.storage.MakeSteps()
storageSteps := a.storage.MakeSteps(to)
for i, storageStep := range storageSteps {
steps[i].storage = storageStep
}
codeSteps := a.code.MakeSteps()
codeSteps := a.code.MakeSteps(to)
for i, codeStep := range codeSteps {
steps[i].code = codeStep
}

View File

@ -1676,12 +1676,17 @@ type HistoryStep struct {
historyFile ctxItem
}
func (h *History) MakeSteps() []*HistoryStep {
// MakeSteps [0, toTxNum)
func (h *History) MakeSteps(toTxNum uint64) []*HistoryStep {
var steps []*HistoryStep
h.InvertedIndex.files.Ascend(func(item *filesItem) bool {
if item.index == nil {
return false
}
if item.startTxNum >= toTxNum {
return true
}
step := &HistoryStep{
compressVals: h.compressVals,
indexItem: item,
@ -1700,6 +1705,9 @@ func (h *History) MakeSteps() []*HistoryStep {
if item.index == nil {
return false
}
if item.startTxNum >= toTxNum {
return true
}
steps[i].historyItem = item
steps[i].historyFile = ctxItem{
startTxNum: item.startTxNum,

View File

@ -55,6 +55,16 @@ func (ii *InvertedIndex) endTxNumMinimax() uint64 {
}
return minimax
}
func (ii *InvertedIndex) endIndexedTxNumMinimax() uint64 {
var max uint64
ii.files.Ascend(func(item *filesItem) bool {
if item.index != nil {
max = cmp.Max(max, item.endTxNum)
}
return true
})
return max
}
func (h *History) endTxNumMinimax() uint64 {
minimax := h.InvertedIndex.endTxNumMinimax()
@ -66,6 +76,17 @@ func (h *History) endTxNumMinimax() uint64 {
}
return minimax
}
func (h *History) endIndexedTxNumMinimax() uint64 {
var max uint64
h.files.Ascend(func(item *filesItem) bool {
if item.index == nil {
return false
}
max = cmp.Max(max, item.endTxNum)
return true
})
return cmp.Min(max, h.InvertedIndex.endIndexedTxNumMinimax())
}
type DomainRanges struct {
valuesStartTxNum uint64