Repository navigation
Update RavenDB to 7.2.7 - #6049
danielmarbach wants to merge 14 commits into
Conversation
cfffa34 to
0899598
Compare
|
Left it in draft since we haven't made a decision to roll this out. We first want to make tests and then decide |
| public static string GenerateDocumentId(this EndpointDocument endpoint) => endpoint.EndpointId.GenerateDocumentId(); | ||
|
|
||
| // Databases created by RavenDB 7.2.5 or later reject control characters in document IDs | ||
| static string? EscapeControlCharacters(string? name) => |
There was a problem hiding this comment.
@danielmarbach this is super interesting as... why would we even allow control characters in document IDs to begin with?
There was a problem hiding this comment.
We don't need to allow it, but the name comes straight from the NServiceBus.OriginatingEndpoint/ProcessingEndpoint headers and nothing validates it. Since 7.2.5, RavenDB throws on such an ID, so the escape is a cheap guard that leaves every normal ID unchanged. Hashing the ID like our other documents would be cleaner, but it means migrating all existing throughput documents, so I'd keep that out of this PR.
ramonsmits
left a comment
There was a problem hiding this comment.
What I like is that I see many test that we actually should have already had. MANY tests which usually is overkill but in case of this engine migration any extra test is useful.
Some minor comments but I don't see anything blocking
ab94a81 to
fab23cb
Compare
Only the embedded lifecycle retried DatabaseLoadTimeoutException. An instance connected to an external server or container failed to start while the server was still loading the database. Both external lifecycles now retry until the host cancels startup, using a shared helper.
…letes GetInstance assigned the static field before the server was reachable and before the database setup finished, while the fast path returned it without taking the semaphore. A test running in parallel could use the server too early and fail with a connection refused error in its setup.
Pin the persister behavior that a RavenDB upgrade can change without a compile error. Approve the client-generated definition of every primary, throughput, and audit index, including the search engine setting that IndexDeployment applies, so a change that would start a side-by-side rebuild shows up as a diff. Deploy each index on its own to an empty database. Check the JSON shape of /admin/debug/memory/stats and /license/status that both persisters read into hand-written types. Check where the JavaScript patches and bulk inserts set @expires, how ingestion orders and de-duplicates attempts by AttemptedAt, and how a retry confirmation compares times. Read throughput time series back through LicensingDataStore. Run audit queries against Lucene and Corax databases. Check that the embedded server writes log files into the log path.
RavenDB 7.2 is the only supported 7.x line, and RavenDB 6.2 support ends in 2027. 7.2.7 contains the compaction, storage, and sorted-query memory fixes that earlier 7.2 patches lack. RavenDB 7 replaced Logs.Mode with Logs.MinLevel and rejects the old option at startup. RavenDBLogLevel now accepts NLog level names as is and translates the legacy mode names the way RavenDB does: None to Off, Operations to Info, Information to Debug. The default stays Warn, which Storage.LogLevel now reports as Warn instead of Operations. The client-side Sparrow.Logging setup no longer exists in RavenDB 7, so the embedded Raven.Embedded log is gone. UseOptimisticConcurrency is obsolete; OptimisticConcurrencyMode.Writes keeps the previous behavior. The ravendb/ravendb images exist only for Ubuntu 24.04 from 7.2.4 on.
Databases created by RavenDB 7.2.5 or later reject document IDs that contain control characters. Throughput document IDs embed the endpoint name, so such a name could not be stored in a new database. IDs without control characters are unchanged, so existing documents still resolve.
SaveEnumsAsIntegers does not apply to patch scripts built from typed patches. Set SaveEnumsAsIntegersForPatching wherever SaveEnumsAsIntegers is set, so a future typed patch cannot write enums as strings.
RavenDB 7.2.7 ships the native ONNX runtime libraries and a local embeddings model that ServiceControl does not use. The server starts and serves Studio without them, which saves about 19 MB in RavenDBServer.zip. The managed AI assemblies stay because Raven.Server loads them at startup.
RavenDB 7.2.0 to 7.2.4 corrupt the attachments index when an operator compacts a database migrated from 6.2 or 7.1. 7.2.5 fixed it and repairs the stale schema when the database loads, so refusing to start on those patches moves operators to a server that repairs their database before a compaction can damage it. The check keeps RavenDB's compatibility rule, which ignores the patch: the server's major.minor must be at least the client's. The 7.2.5 floor is fixed, so a later client patch does not raise the server requirement.
The RavenDB 6.2 to 7.2 data upgrade is one-way, and the 6.x data migrations must finish on RavenDB 6.2 first. Add 6.21.0 as the last version of major 6 to the upgrade path, as 5.11.0 was added for the move to 6. Instances on an older version are told to upgrade to 6.21.0 first.
…og level default The search engine query test expected setup to pin existing databases to Corax, which it no longer does. The embedded lifecycle test asks for info logging so the log directory is created. The index setup wait tolerates the index being absent while it is replaced.
daf035c to
80ee0d1
Compare
An upgrade from ServiceControl 6 to 7 converts the RavenDB database to the RavenDB 7.2 storage format during instance setup. On a large audit database this takes more than a day, while ServiceControl Management said the setup could take several minutes. The installer compares the storage versions declared in the Raven.Server.dll the instance runs with the ones in the bundled RavenDB server. When document or index storage changes for an instance that stores its data in the embedded RavenDB, ServiceControl Management asks for confirmation and shows the database size and, for a running audit instance, an estimate based on the stored message count. During setup it reports the elapsed time every minute. The PowerShell module writes the same text as a warning. Instances on SQL Server or PostgreSQL, and instances with an external RavenDB connection string, get no warning, because their setup does not convert data.
A measurement of the RavenDB conversion on generated audit data shows that every attachment written by RavenDB 6.2 is a chunked stream. The conversion reads the stream info from a data page twice per attachment, and with random document ids the table and tree pages are random reads too. That is 8 to 10 uncached reads per stored message body on a large database, not about 2, so the estimate drops from 600 to 150 messages per second.
An audit database of 525 GB with 101,410,554 stored messages converted in 39.6 hours on hardware that matches the recommended baseline (Azure Premium SSD v2, 6,400 IOPS, 250 MB/s, 4 cores, 32 GB RAM). That is about 711 messages per second, so the estimate uses 700 instead of the earlier inferred 150.
IndexDeployment sends all indexes of a persister in one call, so an index the server rejects blocks the deployment of every other index. These tests deploy each index on its own to a new database and check that it is in the Normal state and uses Lucene. The audit tests also query each index and check the analyzer the server stores for the full-text field. The tests come from the characterization tests in #6049. They use IndexDeployment.FindIndexes and DocumentStoreConventions.Create, which did not exist when that pull request was written.
The index definition approvals now deploy the indexes to a new database on the embedded server before they render the definitions. The approved text is what the server received, including a search engine that IndexDeployment sets on an index. The rendering adds the index type, the source type, compound fields, the archived data behavior, the reduce output index, and every field option the client serializes. IndexDefinitionTests replaces IndexDefinitionApprovals from #6013 in both RavenDB persistence test projects. Both tests share the renderer in TestHelper, so the audit approval covers the same properties as the primary one. The approved maps, reduces, and field options are the same as before. The tests come from the characterization tests in #6049.
|
Closing for now since we will be moving forward with this in some minor after the current major is released |
IndexDeployment sends all indexes of a persister in one call, so an index the server rejects blocks the deployment of every other index. These tests deploy each index on its own to a new database and check that it is in the Normal state and uses Lucene. The audit tests also query each index and check the analyzer the server stores for the full-text field. The tests come from the characterization tests in #6049. They use IndexDeployment.FindIndexes and DocumentStoreConventions.Create, which did not exist when that pull request was written.
The index definition approvals now deploy the indexes to a new database on the embedded server before they render the definitions. The approved text is what the server received, including a search engine that IndexDeployment sets on an index. The rendering adds the index type, the source type, compound fields, the archived data behavior, the reduce output index, and every field option the client serializes. IndexDefinitionTests replaces IndexDefinitionApprovals from #6013 in both RavenDB persistence test projects. Both tests share the renderer in TestHelper, so the audit approval covers the same properties as the primary one. The approved maps, reduces, and field options are the same as before. The tests come from the characterization tests in #6049.
…eployed (#6133) * Publish the shared embedded RavenDB test server only after setup completes GetInstance assigned the static field before the server was reachable and before the database setup finished, while the fast path returned it without taking the semaphore. A test running in parallel could use the server too early and fail with a connection refused error in its setup. * Verify that each RavenDB index deploys on its own IndexDeployment sends all indexes of a persister in one call, so an index the server rejects blocks the deployment of every other index. These tests deploy each index on its own to a new database and check that it is in the Normal state and uses Lucene. The audit tests also query each index and check the analyzer the server stores for the full-text field. The tests come from the characterization tests in #6049. They use IndexDeployment.FindIndexes and DocumentStoreConventions.Create, which did not exist when that pull request was written. * Approve RavenDB index definitions as deployed The index definition approvals now deploy the indexes to a new database on the embedded server before they render the definitions. The approved text is what the server received, including a search engine that IndexDeployment sets on an index. The rendering adds the index type, the source type, compound fields, the archived data behavior, the reduce output index, and every field option the client serializes. IndexDefinitionTests replaces IndexDefinitionApprovals from #6013 in both RavenDB persistence test projects. Both tests share the renderer in TestHelper, so the audit approval covers the same properties as the primary one. The approved maps, reduces, and field options are the same as before. The tests come from the characterization tests in #6049. * Approve audit index definitions on a Lucene database The audit approval deployed to a database without a search engine setting, so IndexDeployment set Lucene on every index and the approved file carried that line on each of them. With the line always present, an index definition that starts to set its own search engine left the approved file unchanged, although RavenDB rebuilds such an index on a database that defaults to Lucene. The audit approval now deploys to a database created with the Lucene settings that DatabaseSetup uses, as the primary approval does. The indexes inherit the search engine, so a Configuration line in an approved file comes from the index definition itself. * Clean up the RavenDB test server and test databases when their setup fails SharedEmbeddedServer left the server running when the connection or the database setup failed after the start. The server was not published, so every later caller tried to start it again and failed with "The server was already started", which hid the first error, and Stop did not dispose it. The server is now disposed when its setup fails, so the next caller starts a new one. ScratchDatabase and CleanDatabaseFixture dispose the document store when creating the database fails or deleting it throws. The audit index searches pass the test timeout token, so a stalled query ends with the test timeout. * Address review comments --------- Co-authored-by: Daniel Marbach <danielmarbach@users.noreply.github.com>
This moves
RavenDB.Embeddedfrom 6.2.18 to 7.2.7. The upgrade changes the on-disk data format and raises the minimum server version for external databases, so we should ship it as ServiceControl 7.Why now
RavenDB 6.2 support ends in 2027. The RavenDB policy page says June 30 and the support page says December 31. ServiceControl 6 remains supported for one year after ServiceControl 7 ships, so the earlier we ship, the more of that year RavenDB still covers. 7.2 is the only supported 7.x line, because 7.0 and 7.1 were short-term releases. 7.2.7 includes the compaction fix for migrated databases from 7.2.5, the storage fixes from 7.2.7, and a fix for excessive memory use in sorted queries.
What changes
We squash-merge, so here are the individual steps:
Retry database load timeouts for external RavenDB servers. Until now, only the embedded lifecycle retried
DatabaseLoadTimeoutException. An instance that connects to an external server or the container now waits for the server to finish loading a large database instead of failing to start. Like the embedded loop, it retries until host startup is cancelled.Publish the shared embedded RavenDB test server only after its setup completes. Tests that started together could reach the server before it was ready.
Add characterization tests for the RavenDB contracts we depend on. These tests change no production code. They cover:
/admin/debug/memory/statsand/license/status@expiresset by patches and bulk inserts, and the JavaScript patch semanticsThe approvals were created on 6.2.18 and pass unchanged on 7.2.7.
Update RavenDB to 7.2.7.
--Logs.Mode, so we pass--Logs.MinLevel.RavenDBLogLevelaccepts NLog level names as they are and translates the legacy names the same way RavenDB does:NonetoOff,OperationstoInfo,InformationtoDebug.Warn, andStorage.LogLevelin the usage report now saysWarninstead ofOperations.Raven.Embeddedlog is gone, because RavenDB 7 removed the Sparrow logging API it relied on.OptimisticConcurrencyMode.Writesreplaces the obsoleteUseOptimisticConcurrencyand keeps the same behavior.SingleNodeBatchCommandno longer takes the session context.ubuntu.24.04, becauseravendb/ravendbpublishes only those tags from 7.2.4 on.Escape control characters in throughput endpoint document IDs. Databases created by RavenDB 7.2.5 or later reject them. Every other ID stays byte-for-byte the same, so existing documents still resolve. A name that already contains a literal
%01maps to the same ID as one with the control character. We accept that, because we don't expect endpoint names like that.Save enums as integers in RavenDB patches.
SaveEnumsAsIntegersForPatchingis now set whereverSaveEnumsAsIntegersis, so a future typed patch cannot write enums as strings.Leave unused RavenDB server libraries out of the package. The ONNX runtime libraries and the local embeddings model no longer ship in
RavenDBServer.zip, which saves about 19 MB. The managed AI assemblies stay, because the server does not start without them.Reject RavenDB 7.2 servers that corrupt migrated databases on compaction. The check keeps RavenDB's compatibility rule, which ignores the patch: the server's major.minor must be at least the client's. On top of that, it rejects 7.2.0 to 7.2.4, because those versions corrupt the attachments index when an operator compacts a database migrated from 6.2 or 7.1. 7.2.5 fixed this and repairs the schema when the database loads, so refusing to start moves operators to a server that repairs their database. The 7.2.5 floor is fixed, so a later client patch does not raise the server requirement. The check handles suffixes such as
-nightly.Require the latest 6.x before upgrading to 7. The installer requires 6.21.0 before an upgrade to 7.0, the same way 5.11.0 gated the move to 6.0.
What operators need to know
servicecontrol-ravendbcontainer must run 7.2.5 or later before the instances are upgraded. We recommend 7.2.7, the version ServiceControl 7 ships with. A 6.x instance still starts against a 7.2 server, because its check only rejects servers with a lower major.minor version. We have not smoke-tested that order yet.Particular.PlatformSample.ServiceControlneeds the .NET 10 runtime 10.0.12 or later, because the RavenDB 7.2.7 server is framework-dependent.message_typesort, can come back in a different order than on 6.2.18. Totals and result sets stay the same.Alternatives we did not take
OperationstoWarn) differs from RavenDB's own translation, so I did not use it.RavenLogManager.Setwould need an adapter for an interface with about 52 members, and it has to run before any RavenDB type loads. That is a lot of code for a log that was only written at the most verbose level.NoCompression, inserts were not faster and used more CPU overall.Related pull requests
RavenExternalPersistenceLifecycleandEmbeddedDatabase, so whichever lands second needs a rebase.How this was verified
Tests ran on macOS arm64 in Release, after the rebase on
master:ServiceControl.Persistence.Tests.RavenDBServiceControl.Audit.Persistence.Tests.RavenDBServiceControl.AcceptanceTests.RavenDBServiceControl.Audit.AcceptanceTests.RavenDBServiceControl.MultiInstance.AcceptanceTestsServiceControlInstaller.Packaging.UnitTestsBeyond the test suites:
servicecontrol-ravendbimage built locally from the 24.04 base, started, reported 7.2.7, and accepted the license.CreatedTimestamp, search engine, and entry counts stayed the same, and polling found noReplacementOf/index.message_typesort keys changed.Still to verify:
ServiceControlInstaller.Engine.UnitTeststargetsnet10.0-windows, so it needs CI. That coversPackagedRavenDBTestsagainst the trimmed zip and the new upgrade gate tests. The gate logic already passed in anet10.0copy.Particular.PlatformSample.ServiceControl.Before this is ready for review