Skip to content

Commit

Permalink
fix stage counter
Browse files Browse the repository at this point in the history
  • Loading branch information
chappjc committed Jul 20, 2021
1 parent 1aab6dd commit 00d5114
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions db/dcrpg/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,13 @@ func (pgb *ChainDB) SyncChainDB(ctx context.Context, client rpcutils.MasterBlock

stages := 2 // without indexing and spend updates, just block import and treasury balance
if reindexing {
stages += 2 // duplicate data removal and indexing
stages += 3 // duplicate data removal, indexing, deep analyze
} else if requireAnalyze {
stages++ // not reindexing, just quick analyzing because far behind
}
if updateAllAddresses {
stages++ // addresses table spending info update
}
if requireAnalyze {
stages++
}

// Safely send sync status updates on barLoad channel, and set the channel
// to nil if the buffer is full.
Expand Down Expand Up @@ -440,7 +439,8 @@ func (pgb *ChainDB) SyncChainDB(ctx context.Context, client rpcutils.MasterBlock
}

// Deep ANALYZE all tables.
log.Infof("Performing an ANALYZE(%d) on all tables...", deepStatsTarget)
stage++
log.Infof("Beginning SYNC STAGE %d of %d (deep database ANALYZE).", stage, stages)
if err = AnalyzeAllTables(pgb.db, deepStatsTarget); err != nil {
return nodeHeight, fmt.Errorf("failed to ANALYZE tables: %v", err)
}
Expand Down Expand Up @@ -489,9 +489,7 @@ func (pgb *ChainDB) SyncChainDB(ctx context.Context, client rpcutils.MasterBlock
// Quickly ANALYZE all tables if not already done after indexing.
if !analyzed && requireAnalyze {
stage++
log.Infof("Beginning SYNC STAGE %d of %d (full database ANALYZE).", stage, stages)
// Analyze all tables.
log.Infof("Performing an ANALYZE(%d) on all tables...", quickStatsTarget)
log.Infof("Beginning SYNC STAGE %d of %d (quick database ANALYZE).", stage, stages)
if err = AnalyzeAllTables(pgb.db, quickStatsTarget); err != nil {
return nodeHeight, fmt.Errorf("failed to ANALYZE tables: %v", err)
}
Expand Down

0 comments on commit 00d5114

Please sign in to comment.