Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/ServiceControl.RavenDB/StartupChecks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,26 @@ public static class StartupChecks
{
public static async Task EnsureServerVersion(IDocumentStore store, CancellationToken cancellationToken = default)
{
// RavenDB compatibility policy is that the major/minor version of the server must be
// equal or higher than the client and ignores the patch version.
//
// https://docs.ravendb.net/6.2/client-api/faq/backward-compatibility/#compatibility---ravendb-42-and-higher
//
// > Starting with version 4.2, RavenDB clients are compatible with any server of their own version and higher.
// > E.g. -
// >
// > Client 4.2 is compatible with Server 4.2, Server 4.5, Server 5.2, and any other server of a higher version.

var build = await store.Maintenance.Server.SendAsync(new GetBuildNumberOperation(), cancellationToken);
var serverProductVersion = new Version(build.ProductVersion);

var clientVersion = typeof(Raven.Client.Constants).Assembly.GetCustomAttributes<AssemblyInformationalVersionAttribute>().First().InformationalVersion;
var parts = clientVersion.Split('.');
var clientProductVersion = $"{parts[0]}.{parts[1]}";
var clientProductVersion = new Version($"{parts[0]}.{parts[1]}");

if (clientProductVersion != build.ProductVersion)
if (clientProductVersion > serverProductVersion)
{
throw new Exception($"ServiceControl expects RavenDB Server version {clientProductVersion} but the server is using {build.ProductVersion}.");
throw new Exception($"ServiceControl expects RavenDB Server version {clientProductVersion} or higher, but the server is using {serverProductVersion}.");
}
}
}
Expand Down
Loading