update stage progress before commit - to keep db always consistent (#1888)

This commit is contained in:
Alex Sharov 2021-05-06 14:18:43 +07:00 committed by GitHub
parent 49225f7319
commit b1dc618b95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View File

@ -159,6 +159,9 @@ func BodiesForward(
return err
}
if !useExternalTx {
if err := s.DoneAndUpdate(tx, bodyProgress); err != nil {
return err
}
if err = tx.CommitAndBegin(context.Background()); err != nil {
return err
}

View File

@ -212,15 +212,15 @@ func SpawnExecuteBlocksStage(s *StageState, stateDB ethdb.Database, toBlock uint
updateProgress := !useBatch || batch.BatchSize() >= int(params.batchSize)
if updateProgress {
if err = s.Update(tx, stageProgress); err != nil {
return err
}
if useBatch {
if err = batch.CommitAndBegin(context.Background()); err != nil {
return err
}
}
if !useExternalTx {
if err = s.Update(tx, stageProgress); err != nil {
return err
}
if err = tx.CommitAndBegin(context.Background()); err != nil {
return err
}

View File

@ -152,6 +152,9 @@ func HeadersForward(
return err
}
if !useExternalTx {
if err = s.Update(tx, headerInserter.GetHighest()); err != nil {
return err
}
if err = tx.CommitAndBegin(context.Background()); err != nil {
return err
}