Skip to content

Fix saving notification settings on RavenDB databases from 6.19 - #5925

Merged
warwickschroeder merged 1 commit into
masterfrom
warwick/notifications-save-collection-mismatch
Sep 25, 2026
Merged

warwickschroeder merged 1 commit into
masterfrom
warwick/notifications-save-collection-mismatch

Conversation

@warwickschroeder

Copy link
Copy Markdown
Contributor

What this fixes

Since 6.20, saving email notification settings fails every time on a RavenDB database that saved them on 6.19 or earlier. This fix does not move old documents into the new collection; they stay where they are and keep working.

  1. RavenDB files every document in a collection named after its C# class.
  2. Up to 6.19, notification settings were saved as class NotificationsSettings, so NotificationsSettings/All sits in the NotificationsSettings collection.
  3. 6.20 renamed the class to NotificationsSettingsDocument, whose collection is NotificationsSettingsDocuments.
  4. 6.20 also changed saving from "load the document and change it" to "write a brand-new object over the same id".
  5. On a database that saved settings on 6.19 or earlier, that write would move the document into the new collection.
  6. RavenDB refuses to move a document between collections and throws DocumentCollectionMismatchException.
  7. So every save of email settings (Configure or the ON/OFF switch) returns 500, and ServicePulse shows UPDATE FAILED. Loading still works.
  8. Databases with no saved settings, and new installs, are unaffected, because there is nothing to clash with.
  9. The fix loads the existing document and changes it in place, so it stays in whichever collection it is already in. A new document is created only when none exists.

Tests

  • ServiceControl.Persistence.Tests.RavenDB: a new test seeds the document in the old NotificationsSettings collection and saves over it. It fails on master with the exception and passes with the fix.
  • ServiceControl.AcceptanceTests.RavenDB: the existing notification tests still pass.
  • Manual, in the embedded ServicePulse: before the fix, both saves return 500 and show UPDATE FAILED; after it, both return 200 and the settings survive a reload.

@warwickschroeder
warwickschroeder merged commit 0f8f02e into master Sep 25, 2026
36 checks passed
@warwickschroeder
warwickschroeder deleted the warwick/notifications-save-collection-mismatch branch September 25, 2026 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants