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

Transaction order during bootstrap and revert #3870

Closed
rainydio opened this issue Jul 3, 2020 · 0 comments
Closed

Transaction order during bootstrap and revert #3870

rainydio opened this issue Jul 3, 2020 · 0 comments
Assignees

Comments

@rainydio
Copy link
Contributor

rainydio commented Jul 3, 2020

Calls to TransactionHistoryService.streamByCriteria currently lack strong guarantee about transaction order. Naturally postgres will return them in order they are stored and that is historical order. Occasionally due to vacuuming order might be messed. Explicit order by is required. The best way to do that is to ORDER BY blocks.height, transactions.sequence, but postgres lacks cross-table indexes to make such ordering efficient. To deal with that block_height column has to be added to transactions table, composite foreign key can be used to ensure that block_id and block_height point to the same row. Then index over transactions(block_height, sequence) can be created and ORDER BY block_height, sequence can be executed quickly.

Later same index can also be used by API to return transactions in reverse order instead of relying on timestamp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants