Repository navigation
Ship RavenDB 6.2 and 7.2 persisters side by side - #6105
Closed
danielmarbach wants to merge 11 commits into
Closed
danielmarbach wants to merge 11 commits into
danielmarbach wants to merge 11 commits into
Conversation
TestHelper is referenced by about 38 test projects and brought RavenDB.Embedded and ServiceControl.RavenDB into every one of them. A test project for the RavenDB 6.2 persisters would therefore get the 7.2 client next to a persister compiled against 6.2. The two RavenDB helpers move to the RavenDB persistence test project and are linked as source by the test projects that use them. The two test projects that used RavenDB types only through TestHelper reference RavenDB.Embedded directly, at the same version as before.
Opening a RavenDB 6.2 database with a 7.2 server converts it one-way, which takes more than a day on a large audit database. An instance that will move to SQL Server or PostgreSQL, or an audit instance that is about to be replaced, should not have to convert first. ServiceControl therefore needs to run on either RavenDB version. The existing RavenDB projects stay the RavenDB 7.2 persisters, now with the manifest name RavenDB7. Three projects without source of their own, ServiceControl.RavenDB6, ServiceControl.Persistence.RavenDB6 and ServiceControl.Audit.Persistence.RavenDB6, link the same source, define RAVENDB6 and build against RavenDB.Embedded 6.2.18. They keep the manifest name RavenDB, with the alias RavenDB6, so existing instances stay on the storage they have. Both flavours keep the same assembly names because stored documents carry assembly-qualified type names. The manifests therefore share a type name, so the lookup matches names and aliases before type names. RavenDB, RavenDB6 and the old type names resolve to the 6.2 persister, and only RavenDB7 resolves to the 7.2 persister. The differences between the two clients sit behind RavenClientCompatibility and RavenServerLogLevel. With RAVENDB6 the behavior is the one on master.
The existing RavenDB test projects test the 7.2 persisters only, so nothing exercised the 6.2 persisters that existing instances keep running on. Four test projects without tests of their own link the sources of the matching RavenDB test project, define RAVENDB6 and reference the 6.2 persisters: ServiceControl.Persistence.Tests.RavenDB6, ServiceControl.Audit.Persistence.Tests.RavenDB6, ServiceControl.AcceptanceTests.RavenDB6 and ServiceControl.Audit.AcceptanceTests.RavenDB6. They form the Raven6 test category, which CI runs next to Raven. Expectations that differ between the versions come from production code, so the tests carry one conditional, the persistence type each flavour selects. EmbeddedServerLoggingTests is excluded from the 6.2 run because it reads a setting that only the 7.2 server reports. Particular.Approvals reads approved files from the running test project, so the 6.2 persistence test projects hold copies of the approved files. The copies are identical: index definitions and persisted types do not differ between the two versions. The multi-instance tests keep running on the 7.2 persisters only.
New instances default to RavenDB 7.2. RavenDB as persistence type now selects the 6.2 persister, so the development configuration of the error and audit instances names RavenDB7.
Each RavenDB persister starts the server it finds in a RavenDBServer folder next to its own assembly, and the two persisters need different servers. The installer shipped one archive, and in CI it held the 7.2 server under the name the 6.2 persister uses. RavenDBServer.zip now holds the 6.2 server, pinned by RavenDB6Version, and RavenDB7Server.zip holds the 7.2 server, pinned by RavenDB.Embedded. The download script used in CI fetches both self-contained servers, and the packaging build fails with the name of the missing folder when one is absent.
A RavenDB 7.2 server that opens a 6.2 database converts it one-way, so the installer must never place a 7.2 server where the 6.2 persister starts it, and must never move an existing instance to RavenDB7 on its own. An instance on RavenDB7 gets the 7.2 server under Persisters\RavenDB7. Every other instance, including those on SQL Server and PostgreSQL, keeps the 6.2 server under Persisters\RavenDB: a migration from RavenDB to SQL reads the old database through the RavenDB persister after the persistence type has changed. The rule lives in RavenDBServerPackage, and an upgrade applies it to the persister the instance already has. New instances, and a forced upgrade that abandons a RavenDB 3.5 database, are created on RavenDB7. The installer resolves persistence names the way the instances do: names and aliases before type names, so RavenDB, RavenDB6 and the old type names select the 6.2 persister. The storage conversion check compares the server the instance runs today with the archive bundled for the persister it will run. Upgrading a ServiceControl 6 instance on RavenDB therefore no longer warns and no longer converts. The check also answers whether moving an instance from RavenDB to RavenDB7 would convert its data.
The platform sample creates fresh databases and references the RavenDB 7.2 server package, but packaged Persisters\RavenDB, which is now the 6.2 persister. It packages Persisters\RavenDB7 instead. A consumer has to set the persistence type to RavenDB7.
New deployments default to RavenDB 7.2, and RavenDB as persistence type now selects the 6.2 persister. The ServiceControl and ServiceControl.Audit images therefore set PersistenceType to RavenDB7. Both persisters are in the images, so a deployment that stays on RavenDB 6 sets PersistenceType to RavenDB.
…ng by accident A RavenDB 7.2 server that opens a 6.2 data directory converts it one-way, which can take days. Deployments usually pin all images to one ServiceControl version, so moving that version from 6 to 7 would start the conversion without anyone having decided to. servicecontrol-ravendb:<tag> is RavenDB 7.2. servicecontrol-ravendb:<tag>-ravendb6 is RavenDB 6.2, for deployments that stay on PersistenceType=RavenDB. Both lines are built for every architecture and published for every tag. The RavenDB 7 image writes a marker file into the data directory. On a data directory that holds databases and no marker it refuses to start, and names the two ways forward: the -ravendb6 tag with PersistenceType=RavenDB, or RAVENDB7_ACCEPT_STORAGE_CONVERSION=true to convert. The RavenDB 6 image refuses to start on a data directory that carries the marker. The variable does not start with RAVEN_ because the server reads those as its settings. The RavenDB 6 image builds from the ubuntu.22.04 base image because RavenDB publishes no ubuntu.24.04 image for 6.2.
The integration test started the instances against the default database image only. An additional case starts them with PersistenceType=RavenDB against the -ravendb6 database image, so the combination that existing deployments stay on is exercised too.
When the RavenDB server is older than the client, ServiceControl told the operator to upgrade the server. For the RavenDB 7.2 persister facing a RavenDB 6 server that advice starts a one-way conversion of the data. The message for a 7.x client and a server before 7 now names both options: stay on RavenDB 6 with PersistenceType=RavenDB and the -ravendb6 database image, or move the server to RavenDB 7, which converts the data. The rule uses the client version the check already receives, so the 6.2 persister keeps the previous message.
Contributor
Author
|
Closing for now since we will be moving forward with this in some minor after the current major is released |
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.
Stacked on #6049. Work in progress; see the status list at the end.
Problem
#6049 moves ServiceControl to RavenDB 7.2. Opening a RavenDB 6.2 database with a 7.2 server converts it one-way. On a large audit database that takes more than a day (measured in #6049: 101 million stored messages in 39.6 hours), and the instance is unavailable until it finishes.
That forces the conversion on everyone who upgrades, including the people for whom it is wasted work:
Change
ServiceControl ships two RavenDB persisters, and an instance stays on the one it has until its operator chooses otherwise.
RavenDB(aliasRavenDB6)RavenDB7RavenDB7.ServiceControl.RavenDB6,ServiceControl.Persistence.RavenDB6andServiceControl.Audit.Persistence.RavenDB6have no source of their own. They link the same source, defineRAVENDB6throughsrc/RavenDB6.propsand build against RavenDB.Embedded 6.2.18.RavenClientCompatibilityandRavenServerLogLevel. Feature code has no conditional compilation. WithRAVENDB6the behavior is the one on master.TestHelperno longer references RavenDB, so a test project can bind either version.Constraints that must hold
RavenPersistedTypes.Verify.approved.txt), so a renamed assembly could not read existing data. The flavours never share a folder: each persister loads from its own directory in its ownPluginAssemblyLoadContext.RavenDBmust never resolve to the 7.2 persister. A wrong match starts a 7.2 server on 6.2 data and converts it. Because the two manifests share a type name, the lookup matches names and aliases across all manifests before it considers type names, and the 6.2 manifest lists its own type name as an alias. Unit tests cover both manifest orders.RavenDB6in its name or sits behindRAVENDB6, so removing it is a deletion.Alternatives considered
Verification
Run on macOS; nothing here has run on Windows yet.
deploy/.../Persisters/RavenDBcarryRaven.Client6.2.18 with a 6.2.18 server; the 7.2 outputs andPersisters/RavenDB7carry 7.2.7 with a 7.2.7 server.ServiceControl.UnitTests, 15 inServiceControl.Audit.UnitTests.Raven6)Raven)The one test of difference in the persistence tests is
EmbeddedServerLoggingTests, which reads a setting that only the 7.2 server reports and is excluded from the 6.2 run. The two skipped acceptance tests are the same on both versions and apply to the SQL persisters. Index definitions and persisted types are identical on both versions: the 6.2 test projects approve against byte-identical copies of the approved files.The packaging and installer changes compile on macOS only. Their tests ran in CI:
Windows-DefaultCore,Linux-DefaultCoreand the Windows installer build pass.The database image was built locally for arm64 in both variants and run against real data: the RavenDB 7 image refused a volume holding a RavenDB 6 database and left it readable by RavenDB 6, converted it once
RAVENDB7_ACCEPT_STORAGE_CONVERSION=truewas set, and the RavenDB 6 image refused the converted volume.Not verified yet: the app images were not built locally, and the image and publishing workflows have only been linted. CI cannot build the app images at the moment because NuGet audit fails on
System.Formats.Cbor10.0.14 (advisory published 2026-11-10, fixed in 10.0.15), which is unrelated to this change and also skips the container integration test.Status
Raven6CI categoryRavenDB7for new instances (compiled on macOS only; the Windows CI run is the verification)RavenDB7as the image default, a-ravendb6tag line for the database image, and a guard against converting by accident (workflows unverified until CI can build the images)docs/packaging.mdanddocs/testing.mddocs/decisions/, if wantedOn the commits before the packaging and installer work, CI passed everything except the eight packaging and installer tests that work updates, including
RavenandRaven6on Windows and Linux.Internal engineering context was checked for this decision area. The records for it are not available to agents, so nothing from them is used here.