Skip to content

Commit

Permalink
RavenDB-20788 : address PR comment - use a different context per command
Browse files Browse the repository at this point in the history
  • Loading branch information
aviv86 committed Jul 16, 2023
1 parent 5265cb8 commit e540a2d
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/Raven.Server/Documents/Sharding/ShardedDocumentDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,23 +242,28 @@ private async Task WaitForConfirmationIndex(long confirmationIndex)
{
var cmd = new WaitForIndexNotificationCommand(new List<long> { confirmationIndex });
var tasks = new List<Task>(ShardingConfiguration.Orchestrator.Topology.Members.Count);
var contexts = new List<IDisposable>(ShardingConfiguration.Orchestrator.Topology.Members.Count);
var clusterTopology = ServerStore.GetClusterTopology();

using (ServerStore.ContextPool.AllocateOperationContext(out JsonOperationContext context))
foreach (var nodeTag in ShardingConfiguration.Orchestrator.Topology.Members)
{
foreach (var nodeTag in ShardingConfiguration.Orchestrator.Topology.Members)
var chosenNode = new ServerNode
{
var chosenNode = new ServerNode
{
ClusterTag = nodeTag,
Database = ShardedDatabaseName,
ServerRole = ServerNode.Role.Member,
Url = clusterTopology.GetUrlFromTag(nodeTag)
};
tasks.Add(ServerStore.ClusterRequestExecutor.ExecuteAsync(chosenNode, nodeIndex: null, context, cmd, token: DatabaseShutdown));
}
ClusterTag = nodeTag,
Database = ShardedDatabaseName,
ServerRole = ServerNode.Role.Member,
Url = clusterTopology.GetUrlFromTag(nodeTag)
};

contexts.Add(ServerStore.ContextPool.AllocateOperationContext(out JsonOperationContext context));
tasks.Add(ServerStore.ClusterRequestExecutor.ExecuteAsync(chosenNode, nodeIndex: null, context, cmd, token: DatabaseShutdown));
}

await Task.WhenAll(tasks);
await Task.WhenAll(tasks);

foreach (var context in contexts)
{
context.Dispose();
}
}

Expand Down

0 comments on commit e540a2d

Please sign in to comment.