This commit is contained in:
Liang Ding 2023-01-09 10:34:37 +08:00
parent c631b64d00
commit dc112fd56c
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 36 additions and 31 deletions

View file

@ -1238,42 +1238,43 @@ func autoFixIndex() {
defer autoFixLock.Unlock()
rootUpdatedMap := treenode.GetRootUpdated()
i := -1
size := len(rootUpdatedMap)
for rootID, updated := range rootUpdatedMap {
if isFullReindexing {
break
}
dbRootUpdatedMap, err := sql.GetRootUpdated()
if nil == err {
i := -1
size := len(rootUpdatedMap)
for rootID, updated := range rootUpdatedMap {
if isFullReindexing {
break
}
i++
i++
rootUpdated, err := sql.GetRootUpdated(rootID)
if nil != err {
continue
}
if "" == rootUpdated {
logging.LogWarnf("not found tree [%s] in database, reindex it", rootID)
reindexTree(rootID, i, size)
continue
}
rootUpdated := dbRootUpdatedMap[rootID]
if "" == rootUpdated {
logging.LogWarnf("not found tree [%s] in database, reindex it", rootID)
reindexTree(rootID, i, size)
continue
}
if "" == updated {
// BlockTree 迁移v2.6.3 之前没有 updated 字段
reindexTree(rootID, i, size)
continue
}
if "" == updated {
// BlockTree 迁移v2.6.3 之前没有 updated 字段
reindexTree(rootID, i, size)
continue
}
btUpdated, _ := time.Parse("20060102150405", updated)
dbUpdated, _ := time.Parse("20060102150405", rootUpdated)
if dbUpdated.Before(btUpdated.Add(-1 * time.Minute)) {
logging.LogWarnf("tree [%s] is not up to date, reindex it", rootID)
reindexTree(rootID, i, size)
continue
btUpdated, _ := time.Parse("20060102150405", updated)
dbUpdated, _ := time.Parse("20060102150405", rootUpdated)
if dbUpdated.Before(btUpdated.Add(-1 * time.Minute)) {
logging.LogWarnf("tree [%s] is not up to date, reindex it", rootID)
reindexTree(rootID, i, size)
continue
}
}
}
duplicatedRootIDs := sql.GetDuplicatedRootIDs()
for _, rootID := range duplicatedRootIDs {
size := len(duplicatedRootIDs)
for i, rootID := range duplicatedRootIDs {
root := sql.GetBlock(rootID)
if nil == root {
continue