Skip to content

Commit

Permalink
RavenDB-17793 : fixes after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
aviv committed Apr 18, 2024
1 parent 0593454 commit 95ba888
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
7 changes: 1 addition & 6 deletions src/Raven.Server/ServerWide/ServerStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/Raven.Server/ServerWide/ShardingStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand All @@ -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);
}
Expand Down
9 changes: 4 additions & 5 deletions src/Raven.Server/Web/System/DatabaseHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand All @@ -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))
{
Expand Down

0 comments on commit 95ba888

Please sign in to comment.