Skip to content

Commit

Permalink
stagedsync: fix astrid sync stage panic due to unintentionally commit…
Browse files Browse the repository at this point in the history
…ted tx (#11629)
  • Loading branch information
taratorio authored Aug 15, 2024
1 parent c746942 commit dfa0625
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions polygon/bridge/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,11 @@ func (s *MdbxStore) PutEvents(ctx context.Context, events []*heimdall.EventRecor
}
defer tx.Rollback()

return PutEvents(tx, events)
if err = PutEvents(tx, events); err != nil {
return err
}

return tx.Commit()
}

func PutEvents(tx kv.RwTx, events []*heimdall.EventRecordWithTime) error {
Expand All @@ -265,7 +269,7 @@ func PutEvents(tx kv.RwTx, events []*heimdall.EventRecordWithTime) error {
}
}

return tx.Commit()
return nil
}

// Events gets raw events, start inclusive, end exclusive
Expand Down Expand Up @@ -308,7 +312,11 @@ func (s *MdbxStore) PutEventIDs(ctx context.Context, eventMap map[uint64]uint64)
}
defer tx.Rollback()

return PutEventsIDs(tx, eventMap)
if err = PutEventsIDs(tx, eventMap); err != nil {
return err
}

return tx.Commit()
}

func PutEventsIDs(tx kv.RwTx, eventMap map[uint64]uint64) error {
Expand All @@ -325,7 +333,7 @@ func PutEventsIDs(tx kv.RwTx, eventMap map[uint64]uint64) error {
}
}

return tx.Commit()
return nil
}

// EventIDRange returns the state sync event ID range for the given block number.
Expand Down

0 comments on commit dfa0625

Please sign in to comment.