From 95ba8888eb99d8b7d8c6d76b14227b332379fe6d Mon Sep 17 00:00:00 2001 From: aviv Date: Sun, 31 Mar 2024 13:55:16 +0300 Subject: [PATCH] RavenDB-17793 : fixes after rebase --- src/Raven.Server/ServerWide/ServerStore.cs | 7 +------ src/Raven.Server/ServerWide/ShardingStore.cs | 4 ++-- src/Raven.Server/Web/System/DatabaseHelper.cs | 9 ++++----- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/Raven.Server/ServerWide/ServerStore.cs b/src/Raven.Server/ServerWide/ServerStore.cs index 63c19940bd1..da157a3a59d 100644 --- a/src/Raven.Server/ServerWide/ServerStore.cs +++ b/src/Raven.Server/ServerWide/ServerStore.cs @@ -2986,12 +2986,7 @@ public void AssignNodesToDatabase(ClusterTopology clusterTopology, string name, throw new ConcurrencyException($"Database '{databaseName}' already exists!"); } - DatabaseHelper.FillDatabaseTopology(this, context, databaseName, record, replicationFactor, index); - - if (record.IsSharded) - { - await Sharding.UpdatePrefixedShardingIfNeeded(context, record); - } + DatabaseHelper.FillDatabaseTopology(this, context, databaseName, record, replicationFactor, index, isRestore); } var addDatabaseCommand = new AddDatabaseCommand(raftRequestId) diff --git a/src/Raven.Server/ServerWide/ShardingStore.cs b/src/Raven.Server/ServerWide/ShardingStore.cs index c972890aa0e..06a9a7c40a2 100644 --- a/src/Raven.Server/ServerWide/ShardingStore.cs +++ b/src/Raven.Server/ServerWide/ShardingStore.cs @@ -153,7 +153,7 @@ private ClusterChanges.DatabaseChangedDelegate CreateDelegateForReshardingStatus }; } - public void FillShardingConfiguration(DatabaseRecord record, ClusterTopology clusterTopology, long? index) + public void FillShardingConfiguration(DatabaseRecord record, ClusterTopology clusterTopology, long? index, bool isRestore) { var shardingConfiguration = record.Sharding; if (shardingConfiguration.BucketRanges == null || @@ -173,7 +173,7 @@ public void FillShardingConfiguration(DatabaseRecord record, ClusterTopology clu } } - if (addDatabase.IsRestore == false && index is null or 0) + if (isRestore == false && index is null or 0) { FillPrefixedSharding(shardingConfiguration); } diff --git a/src/Raven.Server/Web/System/DatabaseHelper.cs b/src/Raven.Server/Web/System/DatabaseHelper.cs index 21a6c922f98..3f8d74e1152 100644 --- a/src/Raven.Server/Web/System/DatabaseHelper.cs +++ b/src/Raven.Server/Web/System/DatabaseHelper.cs @@ -127,7 +127,9 @@ public static void Validate(string name, DatabaseRecord record, RavenConfigurati record.Topology?.ValidateTopology(record.DatabaseName); } } - public static void FillDatabaseTopology(ServerStore server, ClusterOperationContext context, string name, DatabaseRecord record, int replicationFactor, long? index) + + public static void FillDatabaseTopology(ServerStore server, ClusterOperationContext context, string name, DatabaseRecord record, int replicationFactor, + long? index, bool isRestore) { if (replicationFactor <= 0) throw new ArgumentException("Replication factor must be greater than 0."); @@ -147,10 +149,7 @@ public static void FillDatabaseTopology(ServerStore server, ClusterOperationCont if (record.IsSharded) { - server.Sharding.FillShardingConfiguration(record, clusterTopology, index); - - if (server.Sharding.BlockPrefixedSharding && record.Sharding.Prefixed is { Count: > 0 }) - throw new InvalidOperationException("Cannot use prefixed sharding, this feature is currently blocked"); + server.Sharding.FillShardingConfiguration(record, clusterTopology, index, isRestore); if (string.IsNullOrEmpty(record.Sharding.DatabaseId)) {