Skip to content

Conversation

@Alenar
Copy link
Collaborator

@Alenar Alenar commented Jun 24, 2024

Content

This PR:

  • Enable SQLite auto-vacuum for the Cardano transactions databases so they shrink automatically.
  • Make mithril-aggregator & mithril-signer Vacuum their databases at startup (this can take a while so a log message is print).
  • Modify preloading of Cardano transaction in mithril-signer so it execute a Vacuum after each chunk imported.
    We do that since we observed that auto-vacuum isn't executed until the whole import is finished (maybe because the db is a lot busy in this phase) so a manual operation is needed.

Pre-submit checklist

  • Branch
    • Tests are provided (if possible)
    • Crates versions are updated (if relevant)
    • CHANGELOG file is updated (if relevant)
    • Commit sequence broadly makes sense
    • Key commits have useful messages
  • PR
    • No clippy warnings in the CI
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested
  • Documentation
    • Update README file (if relevant)
    • Update documentation website (if relevant)
    • Add dev blog post (if relevant)

Comments

After merging #1766 we observed that the SQLite database file size did not decrease after pruning transactions in signer. This is due to SQLite not automatically reclaiming free pages by itself, we need to use the vacuum operation to do that.

Note: Vacuum reconstruct the SQLite by creating a new file, that mean that it needs an exclusive lock on the database so we can't use it after every deletion carelessly.

For everyday task we enable auto-vacuum that makes SQLite handle it by itself but a the cost of greater fragmentation.
Given this drawback we only enable it on Cardano transactions databases since they are the only one were removal of data occurs on large scale, otherwise simply executing Vacuum at startup is enough.

Issue(s)

Relates to #1766

@Alenar Alenar force-pushed the djo/vacuum_cardano_tx_signer_db branch from d30684f to 574224a Compare June 24, 2024 10:45
@github-actions
Copy link

github-actions bot commented Jun 24, 2024

Test Results

    4 files  ±0     51 suites  ±0   8m 48s ⏱️ +2s
1 090 tests +1  1 090 ✅ +1  0 💤 ±0  0 ❌ ±0 
1 238 runs  +1  1 238 ✅ +1  0 💤 ±0  0 ❌ ±0 

Results for commit 335e28d. ± Comparison against base commit 47c2bb8.

♻️ This comment has been updated with latest results.

@Alenar Alenar temporarily deployed to testing-preview June 24, 2024 11:09 — with GitHub Actions Inactive
@Alenar Alenar temporarily deployed to testing-sanchonet June 24, 2024 11:09 — with GitHub Actions Inactive
Copy link
Collaborator

@sfauvel sfauvel left a comment

Choose a reason for hiding this comment

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

LGTM
Good job

@Alenar Alenar temporarily deployed to testing-preview June 24, 2024 15:26 — with GitHub Actions Inactive
@Alenar Alenar temporarily deployed to testing-sanchonet June 24, 2024 15:26 — with GitHub Actions Inactive
@Alenar Alenar force-pushed the djo/vacuum_cardano_tx_signer_db branch from 78e4efe to f1e3b10 Compare June 25, 2024 07:33
@Alenar Alenar temporarily deployed to testing-sanchonet June 25, 2024 07:40 — with GitHub Actions Inactive
@Alenar Alenar force-pushed the djo/vacuum_cardano_tx_signer_db branch from f1e3b10 to 4edcccf Compare June 25, 2024 13:51
Alenar added 8 commits June 25, 2024 16:13
As it doesn't do any async op underhood.
To execute a sqlite vacuum after a transaction importer work.
…oader

Since it will be the one that will make the db size growing the most and
we wan't to avoid locking the database (as vacuum needs to) in normal
operations.
to limit duplication between aggregator & signer
As it can be very large, contrary to the signer were the
db is pruned regularly.
* Mithril-aggregator from `0.5.25` to `0.5.26`
* Mithril-signer from `0.2.148` to `0.2.149`
* Mithril-persistence from `0.2.9` to `0.4.10`
@Alenar Alenar temporarily deployed to testing-preview June 25, 2024 14:15 — with GitHub Actions Inactive
@Alenar Alenar temporarily deployed to testing-sanchonet June 25, 2024 14:15 — with GitHub Actions Inactive
@Alenar Alenar force-pushed the djo/vacuum_cardano_tx_signer_db branch from 4edcccf to d1f884a Compare June 25, 2024 14:20
@Alenar Alenar force-pushed the djo/vacuum_cardano_tx_signer_db branch from a85e9ec to 335e28d Compare June 25, 2024 14:43
@Alenar Alenar temporarily deployed to testing-preview June 25, 2024 14:50 — with GitHub Actions Inactive
@Alenar Alenar temporarily deployed to testing-sanchonet June 25, 2024 14:50 — with GitHub Actions Inactive
@Alenar Alenar temporarily deployed to testing-preview June 25, 2024 15:00 — with GitHub Actions Inactive
@Alenar Alenar temporarily deployed to testing-sanchonet June 25, 2024 15:00 — with GitHub Actions Inactive
@Alenar Alenar merged commit de439df into main Jun 25, 2024
@Alenar Alenar deleted the djo/vacuum_cardano_tx_signer_db branch June 25, 2024 15:04
@Alenar Alenar mentioned this pull request Jun 28, 2024
12 tasks
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

Successfully merging this pull request may close these issues.

5 participants