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

Extend balances table for better Rosetta #9859

Merged
merged 6 commits into from
Nov 23, 2021

Conversation

psteckler
Copy link
Member

@psteckler psteckler commented Nov 20, 2021

Add extra columns to the balances table in the archive db schema, to speed up Rosetta queries and make them less resource-intensive.

Update the archive processor to populate those extra columns.

There's a new app, migrate_balances_table to convert existing databases to the new format. Tested that app by migrating the replayer test database, then running the replayer, which verifies balances after running each transaction. The replayer found bugs in the migration app. After fixing those bugs, the replayer succeeded.

The migration app add cursor tables to the db, so that if it crashes, the app can be restarted and resuming (approximately) where it left off. The app does not remove those tables, they can be DROPped manually (or I can add an automatic DROP if desired). Such restart capability is needed because Postgresql consumes a lot of memory during the migration -- the 32 Gb on my desktop was exhausted about 1/3 the way through the migration.

(The code for the migration app is a bit quick-n-dirty, sorry, but we'll only need to run it once for each archive db.)

Also: updated extract_blocks to accommodate these changes. After migrating the replayer archive test db, had to run the script to add the chain status column. Ran extract_blocks on a small subchain to test.

@psteckler psteckler requested review from a team as code owners November 20, 2021 03:34
@psteckler psteckler added the ci-build-me Add this label to trigger a circle+buildkite build for this branch label Nov 20, 2021
);

CREATE INDEX idx_balances_id ON balances(id);
CREATE INDEX idx_balances_public_key_id ON balances(public_key_id);
CREATE INDEX idx_balances_height_seq_nos ON balances(block_height,block_sequence_no,block_secondary_sequence_no);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@lk86 lk86 merged commit 6f63ddb into rosetta-1.2.1-safe Nov 23, 2021
@lk86 lk86 deleted the feature/extended-balance-tbl branch November 23, 2021 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-build-me Add this label to trigger a circle+buildkite build for this branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants