Skip to content

Commit

Permalink
piparser: Complete its decoupling in case of its failure
Browse files Browse the repository at this point in the history
Complete the decoupling of piparser in case of its failure.
  • Loading branch information
dmigwi authored and chappjc committed May 28, 2019
1 parent cbe27a2 commit 2aaebc7
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 8 deletions.
7 changes: 6 additions & 1 deletion cmd/rebuilddb2/rebuilddb2.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,15 @@ func mainCore() error {
return err
}

var piParser dcrpg.ProposalsFetcher
if parser != nil {
piParser = parser
}

// Construct a ChainDB without a stakeDB to allow quick dropping of tables.
mpChecker := rpcutils.NewMempoolAddressChecker(client, activeChain)
db, err := dcrpg.NewChainDB(&dbi, activeChain, nil, false, cfg.HidePGConfig, 0,
mpChecker, parser, client)
mpChecker, piParser, client)
if db != nil {
defer db.Close()
}
Expand Down
4 changes: 1 addition & 3 deletions db/dcrpg/pgblockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"fmt"
"reflect"
"runtime"
"runtime/debug"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -1119,15 +1118,14 @@ func (pgb *ChainDB) VotesInBlock(hash string) (int16, error) {
func (pgb *ChainDB) proposalsUpdateHandler() {
// Do not initiate the async update if invalid piparser instance was found.
if pgb.piparser == nil {
log.Debug("invalid piparser instance was found: async update stopped")
log.Error("invalid piparser instance was found: async update stopped")
return
}

go func() {
defer func() {
if r := recover(); r != nil {
log.Errorf("recovered from piparser panic in proposalsUpdateHandler: %v", r)
log.Errorf(string(debug.Stack()))
select {
case <-time.NewTimer(time.Minute).C:
log.Infof("attempting to restart proposalsUpdateHandler")
Expand Down
2 changes: 1 addition & 1 deletion gov/politeia/proposals.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ func (db *ProposalDB) CheckProposalsUpdates() error {
// Retrieve and update any new proposals created since the previous
// proposals were stored in the db.
lastProposal, err := db.lastSavedProposal()
if err != nil {
if err != nil && err != storm.ErrNotFound {
return fmt.Errorf("lastSavedProposal failed: %v", err)
}

Expand Down
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ func _main(ctx context.Context) error {
log.Error(err)
}

var piParser dcrpg.ProposalsFetcher
if parser != nil {
piParser = parser
}

// Auxiliary DB (PostgreSQL)
var newPGIndexes, updateAllAddresses, updateAllVotes bool
pgHost, pgPort := cfg.PGHost, ""
Expand Down Expand Up @@ -215,7 +220,7 @@ func _main(ctx context.Context) error {
mpChecker := rpcutils.NewMempoolAddressChecker(dcrdClient, activeChain)
chainDB, err := dcrpg.NewChainDBWithCancel(ctx, &dbi, activeChain,
stakeDB, !cfg.NoDevPrefetch, cfg.HidePGConfig, rowCap,
mpChecker, parser, dcrdClient)
mpChecker, piParser, dcrdClient)
if chainDB != nil {
defer chainDB.Close()
}
Expand Down
1 change: 1 addition & 0 deletions public/js/controllers/proposal_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ let common = {
fillGraph: true,
strokeWidth: 2,
gridLineColor: '#C4CBD2',
labelsUTC: true,
legendFormatter: legendFormatter
}

Expand Down
2 changes: 1 addition & 1 deletion views/agenda.tmpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{define "agenda"}}
<!DOCTYPE html>
<html lang="en">
{{template "html-head" printf "Decred Vote Agenda Pages"}}
{{template "html-head" printf "Decred Agenda Charts"}}
{{template "navbar" .}}
{{with .Ai}}
<div class="container main">
Expand Down
2 changes: 1 addition & 1 deletion views/proposal.tmpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{define "proposal"}}
<!DOCTYPE html>
<html lang="en">
{{template "html-head" printf "Decred Vote Proposal Pages"}}
{{template "html-head" printf "Decred Proposal Charts"}}
{{template "navbar" .}}
{{with .Data}}
<div class="container">
Expand Down

0 comments on commit 2aaebc7

Please sign in to comment.