Repository navigation
GH-6137 Message store migrations never drop what the running version does not declare - #6138
Open
cyclr-adrian wants to merge 1 commit into
Open
cyclr-adrian wants to merge 1 commit into
cyclr-adrian wants to merge 1 commit into
Conversation
…version does not declare The store was migrated under CreateOrUpdate, which drops the columns, indexes and foreign keys a table model does not declare. A node on an older version (its startup migration, or resources setup) therefore stripped what a newer version had added to the store, while nodes on the newer version still used it: the dead letter columns and their data, the JasperFxGH-5498 node record index. Every table the relational stores migrate is now AddOnlyMigrations (weasel#629), as the database queue tables already are. Weasel keeps additions and changes, withholds the drops and logs them. MessageStoreResource.Setup's comment no longer claims CreateOrUpdate never drops anything.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the add-only message-store migration changes.
No open issues 🎉
What changed in this PR
Addresses GH-6137 by making relational message-store migrations add-only, protecting schema additions from newer versions during rollbacks and rolling deployments.
Changes:
- Applies a shared add-only helper to RDBMS and Oracle migration paths.
- Adds MySQL regression tests for preserving extra columns, data, and indexes while still creating declared indexes.
- Corrects comments describing migration behavior.
| File | Description |
|---|---|
| src/Wolverine/Persistence/Durability/MessageStoreResource.cs | Corrects setup migration comments. |
| src/Persistence/Wolverine.RDBMS/MessageDatabase.Weasel.cs | Applies add-only behavior to shared store objects. |
| src/Persistence/Wolverine.RDBMS/AddOnlyStoreSchema.cs | Adds the shared table-marking helper. |
| src/Persistence/Oracle/Wolverine.Oracle/OracleMessageStore.Weasel.cs | Marks Oracle schema objects add-only. |
| src/Persistence/Oracle/Wolverine.Oracle/OracleMessageStore.Admin.cs | Protects Oracle’s direct migration path. |
| src/Persistence/MySql/Wolverine.MySql/MySqlMessageStore.cs | Updates the index migration comment. |
| src/Persistence/MySql/MySqlTests/Bug_6137_message_store_migrations_are_add_only.cs | Adds schema preservation and migration regression tests. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #6137.
The message store was migrated under
CreateOrUpdate, which drops the columns, indexes and foreign keys a table model doesn't declare (#873). So a node on an older Wolverine stripped what a newer version had added to the store, either through its startup migration or throughresources setup/AddResourceSetupOnStartup(). Nodes still on the newer version then broke: the dead letter columns and their data went, and so did the GH-5498 node record index.Change
Wolverine.RDBMS.AddOnlyStoreSchema.AddOnly(). It setsITable.AddOnlyMigrations(weasel#629) on every table among the store's objects. Weasel then keeps additions and changes, withholds the drops, and logs each one it withholds.MessageDatabase.Objects. MySQL, PostgreSQL, SQL Server and SQLite migrate from it, including tenant databases, and so do Marten and Polecat through the PostgreSQL and SQL Server stores.ObjectsandOracleMessageStore.Admin.MigrateAsync, which readsAllObjects()directly.Schema/*Tableconstructor and on each inline node, assignment, control queue and node record table, so a table added later can't miss it.MessageStoreResource.Setupcomment no longer saysCreateOrUpdatenever drops data. A MySQL MySQL: wolverine_node_records housekeeping deadlocks (row trim vs inserts, age sweep vs row trim) #5498 comment that said an outside index is dropped by the next migration is updated too.This is the trade-off
QueueTableandScheduledMessageTablealready accept: a release that really needs to remove a column or index from the store now has to do it explicitly.Tests
MySqlTests/Bug_6137_message_store_migrations_are_add_only.cschecks four things:Objectsis add-only;MigrateAsync(AutoCreate.CreateOrUpdate), which is whatSetupruns;Without the
MessageDatabase.Objectschange, the first three fail. Run locally on .NET 11:I didn't run the PostgreSQL, SQL Server or Oracle suites locally.
Backport
Please consider a 6.x backport. The flag only protects a rollback to a version that has it, so the sooner it's in a 6.x release, the more rollbacks it covers, including 7.0 → 6.x. The same change applies to the
6.0branch:MessageDatabase.Objects, plus Oracle's two call sites, if they're the same there. I'm happy to open that PR as well.Related: JasperFx/weasel#924 / JasperFx/weasel#925. Weasel.MySql drops a column before its index, which gives error 1091 and a half-applied migration. This PR stops Wolverine's store from emitting those drops at all.
🤖 Generated with Claude Code