|
The idea here is to implement a persistent script which can automatically modify the storage format when upgrading/downgrading versions that may break compatibility. Consider the following sequence of events:
- User upgrades from v2.6 to v2.8 and starts mongod.
- mongod stores a set of migration scripts in a serialized file.
- mongod migrates the datafiles to a new format and bumps the pdfile version.
- User downgrades to v2.6
- mongod sees pdfile version is for v2.8, then looks for a 'v2.8 to v2.6' migration script.
- If found, mongod executes the script.
- Otherwise, existing behavior is preserved.
- mongod overwrites the pdfile version to v2.6 (possibly storing a list of past version migrations).
If, for example, the format change involved a new data structure for free space management, the script could be written to either execute a repair operation, or read the v2.8 data structure(s) and write out the v2.6 data structure(s).
|