[NOD-765] Fix database corruption after restart in reachabilitystore and utxodiffstore. (#634)

This commit is contained in:
stasatdaglabs 2020-02-18 12:04:50 +02:00 committed by GitHub
parent dd4c93e1ef
commit 243b4b8021
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 1 deletions

View File

@ -339,8 +339,8 @@ func (rtn *reachabilityTreeNode) countSubtrees(subTreeSizeMap map[*reachabilityT
func (rtn *reachabilityTreeNode) propagateInterval(subTreeSizeMap map[*reachabilityTreeNode]uint64) ([]*reachabilityTreeNode, error) {
// We set the interval to reset its remainingInterval, so we could reallocate it while reindexing.
rtn.setInterval(rtn.interval)
modifiedNodes := []*reachabilityTreeNode{rtn}
queue := []*reachabilityTreeNode{rtn}
var modifiedNodes []*reachabilityTreeNode
for len(queue) > 0 {
var current *reachabilityTreeNode
current, queue = queue[0], queue[1:]

View File

@ -88,6 +88,7 @@ func (store *reachabilityStore) flushToDB(dbTx database.Tx) error {
}
for hash := range store.dirty {
hash := hash // Copy hash to a new variable to avoid passing the same pointer
reachabilityData := store.loaded[hash]
err := store.dbStoreReachabilityData(dbTx, &hash, reachabilityData)
if err != nil {

View File

@ -166,6 +166,7 @@ func (diffStore *utxoDiffStore) flushToDB(dbTx database.Tx) error {
// while writing each entry.
buffer := &bytes.Buffer{}
for hash := range diffStore.dirty {
hash := hash // Copy hash to a new variable to avoid passing the same pointer
buffer.Reset()
diffData := diffStore.loaded[hash]
err := dbStoreDiffData(dbTx, buffer, &hash, diffData)