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

Feature/migrate modification history #2260

Open
wants to merge 33 commits into
base: master
Choose a base branch
from

Conversation

acerone85
Copy link
Contributor

Linked Issues/PRs

Closes #2095

Description

  • Builds on top of Versioned Storage for Modifications History #2233, which defines the migration functions for the modifications history
  • Defines rocksdb specific handles for the combined database (available only when the feature "rocksdb" is specified), which are necessary to access the functions for performing the migration
  • Spins 4 blocking tasks, one for each database, to perform the migration in parallel with the startup of the Fuel service

Questions:

  • Do we want to handle graceful shutdown of the migration service?
  • How do we test this over a large amount of data?

Checklist

  • Breaking changes are clearly marked as such in the PR description and changelog
  • New behavior is reflected in tests
  • The specification matches the implemented behavior (link update PR if changes are needed)

Before requesting review

  • I have reviewed the code myself
  • I have created follow-up issues caused by this PR and linked them here

After merging, notify other teams

[Add or remove entries as needed]

CHANGELOG.md Outdated Show resolved Hide resolved
bin/fuel-core/src/cli/run.rs Outdated Show resolved Hide resolved
crates/fuel-core/src/state/historical_rocksdb.rs Outdated Show resolved Hide resolved
Comment on lines 640 to 637
while let Err(e) =
rocks_db.migrate_modifications_history_at_height(height)
{
tracing::warn!("Could not migrate modifications history at height {height}: {e:?}. Trying again.")
}
}
}
rocks_db.complete_migration();
Copy link
Contributor

Choose a reason for hiding this comment

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

In case of Err we will just warn in log and continue with next entry, and then call complete_migration();.

I'm wondering if this leaves some entries not migrated? And if this is acceptable outcome.

I may be lacking some context, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good question. I also lack context to answer, probably @xgreenx knows

Copy link
Contributor Author

@acerone85 acerone85 Sep 30, 2024

Choose a reason for hiding this comment

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

Ah, I missed the point of your question. The rationale behind the loop is because I don't know whether we use pessmiistic or optimistic concurrency control, e.g. whether the migration transaction aborts in case of conflict. In the latter case, we need to retry the transaction. But if we employ pessimistic concurrency control then the loop is not necessary

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need to skip failed entry and continue. But with changes that I asked from #2233 (comment), you will not have cases where error can occur.

crates/fuel-core/src/state/historical_rocksdb.rs Outdated Show resolved Hide resolved
@acerone85 acerone85 force-pushed the feature/migrate-modification-history branch from a29e3a8 to e671b0c Compare September 30, 2024 13:44
@acerone85 acerone85 force-pushed the feature/version-modifications-history branch from 910186c to fe3e453 Compare September 30, 2024 15:55
@acerone85 acerone85 force-pushed the feature/migrate-modification-history branch 2 times, most recently from 5c70a37 to a3ecd66 Compare September 30, 2024 17:01
// TODO: Handle graceful shutdown of migration processes
#[cfg(feature = "rocksdb")]
{
let on_chain_migration_handle = combined_database
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the HistoricalRocksDB should be responsible for launching the migration on construction.

@@ -329,10 +352,14 @@ where
fn rollback_block_to(&self, height_to_rollback: u64) -> StorageResult<()> {
let mut storage_transaction = self.db.read_transaction();

let modifications_history_migration_in_progress = self
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like would be nice to have a getter for this field=)

Comment on lines 640 to 637
while let Err(e) =
rocks_db.migrate_modifications_history_at_height(height)
{
tracing::warn!("Could not migrate modifications history at height {height}: {e:?}. Trying again.")
}
}
}
rocks_db.complete_migration();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need to skip failed entry and continue. But with changes that I asked from #2233 (comment), you will not have cases where error can occur.

@acerone85 acerone85 force-pushed the feature/version-modifications-history branch from 8d4bd59 to 9e6247a Compare October 1, 2024 17:45
@acerone85 acerone85 force-pushed the feature/migrate-modification-history branch 2 times, most recently from 943f60c to 0ff920e Compare October 1, 2024 19:01
@acerone85 acerone85 force-pushed the feature/version-modifications-history branch from 9e6247a to f787cf6 Compare October 2, 2024 14:04
@acerone85 acerone85 force-pushed the feature/migrate-modification-history branch 2 times, most recently from 8ac1bf0 to db2ffc5 Compare October 2, 2024 15:50
@acerone85 acerone85 force-pushed the feature/version-modifications-history branch from f787cf6 to 308c34a Compare October 3, 2024 15:57
@acerone85 acerone85 force-pushed the feature/migrate-modification-history branch from 7c1e835 to e1bc889 Compare October 3, 2024 15:57
@acerone85 acerone85 force-pushed the feature/version-modifications-history branch from 308c34a to 3c9eff4 Compare October 3, 2024 16:45
@acerone85 acerone85 force-pushed the feature/migrate-modification-history branch from e1bc889 to 14540b7 Compare October 3, 2024 16:46
@acerone85 acerone85 force-pushed the feature/migrate-modification-history branch from 14540b7 to aff310a Compare October 4, 2024 10:34
@acerone85 acerone85 force-pushed the feature/migrate-modification-history branch from aff310a to a3f9c25 Compare October 10, 2024 15:27
AurelienFT
AurelienFT previously approved these changes Oct 29, 2024
@acerone85 acerone85 force-pushed the feature/migrate-modification-history branch from db51eeb to dbc1786 Compare October 31, 2024 15:37
xgreenx added a commit that referenced this pull request Nov 27, 2024
## Linked Issues/PRs
<!-- List of related issues/PRs -->

Related to #2095

## Description
<!-- List of detailed changes -->

- [ ] Adds a ModificationsHistoryV2 column in the Historical RocksDB,
with keys encoded in big endian
- [ ] Adds a flag to the historical RocksDB that keeps track whether the
migration is still in progress

- [ ] Change HistoricalRocksDB to alway insert historical changes from
V2 table. When the migration is in progress, delete key-value pairs from
both V2 and V2, read key-value pairs from V2 falling back to V1 if no
value in V2 is found

#TODO (either this or next MR): 
- [x] Small task that performs the migration of key-value pairs from V1
to V2 (Done in #2260)

## Checklist
- [ ] Breaking changes are clearly marked as such in the PR description
and changelog
- [x] New behavior is reflected in tests
- [ ] [The specification](https://github.com/FuelLabs/fuel-specs/)
matches the implemented behavior (link update PR if changes are needed)

### Before requesting review
- [ ] I have reviewed the code myself
- [ ] I have created follow-up issues caused by this PR and linked them
here

### After merging, notify other teams

[Add or remove entries as needed]

- [ ] [Rust SDK](https://github.com/FuelLabs/fuels-rs/)
- [ ] [Sway compiler](https://github.com/FuelLabs/sway/)
- [ ] [Platform
documentation](https://github.com/FuelLabs/devrel-requests/issues/new?assignees=&labels=new+request&projects=&template=NEW-REQUEST.yml&title=%5BRequest%5D%3A+)
(for out-of-organization contributors, the person merging the PR will do
this)
- [ ] Someone else?

---------

Co-authored-by: Green Baneling <[email protected]>
Base automatically changed from feature/version-modifications-history to master November 27, 2024 14:35
@xgreenx xgreenx dismissed AurelienFT’s stale review November 27, 2024 14:35

The base branch was changed.

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.

4 participants