Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

services/horizon: Fix reingestion for the history_{transaction,operation}_claimable_balances tables #3661

Merged
merged 5 commits into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions services/horizon/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ file. This project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

### Code Changes

* Fix bug in `horizon db reingest range` command, which would throw a duplicate entry conflict error from the DB. ([3661](https://github.com/stellar/go/pull/3661)).

## v2.4.0

**Upgrading to this version from <= v2.1.1 will trigger a state rebuild. During this process (which can take up to 20 minutes), Horizon will not ingest new ledgers.**
Expand Down
43 changes: 15 additions & 28 deletions services/horizon/internal/db2/history/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -826,34 +826,21 @@ func (q *Q) CloneIngestionQ() IngestionQ {
// DeleteRangeAll deletes a range of rows from all history tables between
// `start` and `end` (exclusive).
func (q *Q) DeleteRangeAll(ctx context.Context, start, end int64) error {
err := q.DeleteRange(ctx, start, end, "history_effects", "history_operation_id")
if err != nil {
return errors.Wrap(err, "Error clearing history_effects")
for table, column := range map[string]string{
"history_effects": "history_operation_id",
"history_ledgers": "id",
"history_operation_claimable_balances": "history_operation_id",
"history_operation_participants": "history_operation_id",
"history_operations": "id",
"history_trades": "history_operation_id",
"history_transaction_claimable_balances": "history_transaction_id",
"history_transaction_participants": "history_transaction_id",
"history_transactions": "id",
} {
err := q.DeleteRange(ctx, start, end, table, column)
if err != nil {
return errors.Wrapf(err, "Error clearing %s", table)
}
}
err = q.DeleteRange(ctx, start, end, "history_operation_participants", "history_operation_id")
if err != nil {
return errors.Wrap(err, "Error clearing history_operation_participants")
}
err = q.DeleteRange(ctx, start, end, "history_operations", "id")
if err != nil {
return errors.Wrap(err, "Error clearing history_operations")
}
err = q.DeleteRange(ctx, start, end, "history_transaction_participants", "history_transaction_id")
if err != nil {
return errors.Wrap(err, "Error clearing history_transaction_participants")
}
err = q.DeleteRange(ctx, start, end, "history_transactions", "id")
if err != nil {
return errors.Wrap(err, "Error clearing history_transactions")
}
err = q.DeleteRange(ctx, start, end, "history_ledgers", "id")
if err != nil {
return errors.Wrap(err, "Error clearing history_ledgers")
}
err = q.DeleteRange(ctx, start, end, "history_trades", "history_operation_id")
if err != nil {
return errors.Wrap(err, "Error clearing history_trades")
}

return nil
}
6 changes: 3 additions & 3 deletions services/horizon/internal/test/scenarios/bindata.go

Large diffs are not rendered by default.

Loading