[−][src]Function exonum_merkledb::migration::flush_migration
pub fn flush_migration(fork: &mut Fork, namespace: &str)
Flushes the migration to the fork. Once the fork
is merged, the migration is complete.
The following operations will be performed:
- Migrated indexes will replace their old versions
- Migrated indexes will be aggregated in the default namespace
- Indexes marked with tombstones will be removed
- Scratchpad associated with the migration will be cleared
Safety
Flushing a migration must be performed on a fork
which contains the final migration
changes. Not doing so may break the state aggregation in the database. A scenario when
this requirement would be violated is as follows:
- Start a database migration in a separate thread, constructing a
MigrationHelper
aroundArc<dyn Database>
. - Create a fork.
- Ensure that the migration is complete via some synchronization primitive.
- Call
flush_migration
on the fork from step 2.
In this scenario, a fork may not have the latest migration data because it was created before the migration is complete. The correct workflow would be to swap steps 2 and 3, i.e., first ensure that the migration is complete and then create a fork in which it will be flushed.