Skip to content

Commit 96f3b32

Browse files
ramonsmitsbording
andauthored
Check that server version is greater than or equal to the client (#5111)
Co-authored-by: Brandon Ording <[email protected]>
1 parent fa7ed5a commit 96f3b32

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/ServiceControl.RavenDB/StartupChecks.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,26 @@ public static class StartupChecks
99
{
1010
public static async Task EnsureServerVersion(IDocumentStore store, CancellationToken cancellationToken = default)
1111
{
12+
// RavenDB compatibility policy is that the major/minor version of the server must be
13+
// equal or higher than the client and ignores the patch version.
14+
//
15+
// https://docs.ravendb.net/6.2/client-api/faq/backward-compatibility/#compatibility---ravendb-42-and-higher
16+
//
17+
// > Starting with version 4.2, RavenDB clients are compatible with any server of their own version and higher.
18+
// > E.g. -
19+
// >
20+
// > Client 4.2 is compatible with Server 4.2, Server 4.5, Server 5.2, and any other server of a higher version.
21+
1222
var build = await store.Maintenance.Server.SendAsync(new GetBuildNumberOperation(), cancellationToken);
23+
var serverProductVersion = new Version(build.ProductVersion);
1324

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

18-
if (clientProductVersion != build.ProductVersion)
29+
if (clientProductVersion > serverProductVersion)
1930
{
20-
throw new Exception($"ServiceControl expects RavenDB Server version {clientProductVersion} but the server is using {build.ProductVersion}.");
31+
throw new Exception($"ServiceControl expects RavenDB Server version {clientProductVersion} or higher, but the server is using {serverProductVersion}.");
2132
}
2233
}
2334
}

0 commit comments

Comments
 (0)