Skip to content

Commit

Permalink
RavenDB-22634 : prevent creating a database with prefixed sharding en…
Browse files Browse the repository at this point in the history
…abled in a mixed cluster of 6.1 and 6.0
  • Loading branch information
aviv committed Aug 19, 2024
1 parent 179aaff commit cf8c440
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Raven.Server/Web/System/AdminDatabasesHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
using Raven.Client.Documents.Operations;
using Raven.Client.Documents.Smuggler;
using Raven.Client.Exceptions;
using Raven.Client.Exceptions.Cluster;
using Raven.Client.Exceptions.Database;
using Raven.Client.Exceptions.Sharding;
using Raven.Client.Extensions;
Expand All @@ -33,7 +32,6 @@
using Raven.Server.Config.Settings;
using Raven.Server.Documents;
using Raven.Server.Documents.Commands;
using Raven.Server.Documents.Handlers.Processors.Stats;
using Raven.Server.Documents.Indexes.Auto;
using Raven.Server.Documents.Operations;
using Raven.Server.Documents.Patch;
Expand Down Expand Up @@ -271,6 +269,14 @@ public async Task Put()
}
}

if (databaseRecord.IsSharded && databaseRecord.Sharding.Prefixed.Count > 0)
{
if (ServerStore.Engine.CommandsVersionManager.CurrentClusterMinimalVersion < 61_000)
throw new InvalidOperationException($"Cannot enable Prefixed Sharding for database '{databaseRecord.DatabaseName}'. " +
$"Some nodes in the cluster are running older versions of RavenDB that do not support the Prefixed Sharding feature. " +
$"To use Prefixed Sharding, all cluster nodes must be running version 6.1 or later.");
}

using (var raw = new RawDatabaseRecord(context, json))
{
foreach (var rawDatabaseRecord in raw.AsShardsOrNormal())
Expand Down

0 comments on commit cf8c440

Please sign in to comment.