core: Save schema version for intermediate steps #364
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In short
schemaversion
for each successful intermediate upgradeRationale
These changes
When running upgrade queries, update the schema version for each intermediate step. This ensures that any interrupted upgrades have a greater chance of resuming correctly after core restart.
Almost all databases make single queries atomic (fully works or fully fails, no partial), and with many of the longest migrations being a single query, this makes upgrade interruptions much more likely to leave the database in a valid intermediate schema version.
As a side effect, downgrading from a partial upgrade will now require setting schema version manually, instead of it possibly happening to work depending on what changed. An unsupported operation failing in a known, recoverable way seems better than failing in an unknown, possibly recoverable way.
Future work
In the future, for databases that support it (e.g. almost only PostgreSQL), we may want to wrap upgrades in a transaction. This will need careful testing of potential additional space requirements and any database modifications that might not be allowed in a transaction.
For sake of time, the above was copied from the commit message.
Examples
Interrupted upgrade procedure
Steps
kill -9
) interrupting upgrade when it reaches a long single-query migrationCommands run
run-profile.sh
is a script to simplify managing multiple testing copies of Quassel and is equivalent to calling the rightquasselcore
with the right optionsInterrupted upgrade log