Skip to content

Commit

Permalink
RavenDB-20788 : address PR comment
Browse files Browse the repository at this point in the history
  • Loading branch information
aviv86 committed Jul 18, 2023
1 parent cc91e57 commit d4d43f8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Raven.Server/Documents/Sharding/ShardedDocumentDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public async Task DeleteBucketAsync(int bucket, long migrationIndex, long confir

// before starting cleanup, wait for DestinationMigrationConfirm command
// to be applied in all orchestrator nodes
await WaitForConfirmationIndex(confirmationIndex);
await WaitForOrchestratorConfirmationAsync(confirmationIndex);

while (true)
{
Expand All @@ -238,7 +238,7 @@ public async Task DeleteBucketAsync(int bucket, long migrationIndex, long confir
}
}

private async Task WaitForConfirmationIndex(long confirmationIndex)
private async Task WaitForOrchestratorConfirmationAsync(long confirmationIndex)
{
var cmd = new WaitForIndexNotificationCommand(new List<long> { confirmationIndex });
var tasks = new List<Task>(ShardingConfiguration.Orchestrator.Topology.Members.Count);
Expand All @@ -260,7 +260,14 @@ private async Task WaitForConfirmationIndex(long confirmationIndex)
tasks.Add(t);
}

await Task.WhenAll(tasks);
try
{
await Task.WhenAll(tasks);
}
catch (Exception e)
{
throw new InvalidOperationException($"failed to wait for migration confirmation index '{confirmationIndex}' on Orchestrator nodes: {ShardingConfiguration.Orchestrator.Topology}. Error : {e}");
}
}

public static ShardedDocumentDatabase CastToShardedDocumentDatabase(DocumentDatabase database) => database as ShardedDocumentDatabase ?? throw new ArgumentException($"Database {database.Name} must be sharded!");
Expand Down

0 comments on commit d4d43f8

Please sign in to comment.