-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
base: feature/version-modifications-history
Are you sure you want to change the base?
Feature/migrate modification history #2260
Conversation
bin/fuel-core/src/cli/run.rs
Outdated
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(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
a29e3a8
to
e671b0c
Compare
910186c
to
fe3e453
Compare
5c70a37
to
a3ecd66
Compare
bin/fuel-core/src/cli/run.rs
Outdated
// TODO: Handle graceful shutdown of migration processes | ||
#[cfg(feature = "rocksdb")] | ||
{ | ||
let on_chain_migration_handle = combined_database |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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=)
bin/fuel-core/src/cli/run.rs
Outdated
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(); |
There was a problem hiding this comment.
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.
8d4bd59
to
9e6247a
Compare
943f60c
to
0ff920e
Compare
9e6247a
to
f787cf6
Compare
8ac1bf0
to
db2ffc5
Compare
f787cf6
to
308c34a
Compare
7c1e835
to
e1bc889
Compare
308c34a
to
3c9eff4
Compare
a3f9c25
to
4e7e614
Compare
ConflictPolicy::Overwrite, | ||
Changes::default(), | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can add assert here? It's not crucial, but helps a bit with the clarity of the flow.
let v1_changes = historical_rocks_db
.db
.iter_all::<ModificationsHistoryV1<OnChain>>(None)
.count();
let v2_changes = historical_rocks_db
.db
.iter_all::<ModificationsHistoryV2<OnChain>>(None)
.count();
assert_eq!(v1_changes, 0);
assert_eq!(v2_changes, 100);
.rollback_last_block() | ||
{ | ||
// If rolling back fails, then cumulative changes are not being committed to rocksDB. | ||
// We flush them the DB to keep the migration going. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
Looks like an incomplete comment.
historical_rocksdb: Arc<InnerHistoricalRocksDB<Description>>, | ||
) { | ||
historical_rocksdb.is_migration_in_progress().then(|| { | ||
tokio::task::spawn_blocking(move || { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there currently a way to gracefully interrupt this migration, if need be?
db51eeb
to
dbc1786
Compare
Linked Issues/PRs
Closes #2095
Description
Questions:
Checklist
Before requesting review
After merging, notify other teams
[Add or remove entries as needed]