This is an automated email from the ASF dual-hosted git repository.
ptupitsyn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new 562721aed0 IGNITE-18794 .NET: Fix DivideByZeroException in
GetPreferredNode (#1669)
562721aed0 is described below
commit 562721aed06b75fa77e649b43b2c3d75e62b84e0
Author: Pavel Tupitsyn <[email protected]>
AuthorDate: Tue Feb 14 15:34:07 2023 +0200
IGNITE-18794 .NET: Fix DivideByZeroException in GetPreferredNode (#1669)
Partition assignment can be null or empty on table drop. Skip awareness
logic in this case.
---
.../dotnet/Apache.Ignite/Internal/Table/Table.cs | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/modules/platforms/dotnet/Apache.Ignite/Internal/Table/Table.cs
b/modules/platforms/dotnet/Apache.Ignite/Internal/Table/Table.cs
index 2e110f246b..d929994658 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Internal/Table/Table.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Internal/Table/Table.cs
@@ -194,13 +194,20 @@ namespace Apache.Ignite.Internal.Table
}
var assignment = await
GetPartitionAssignmentAsync().ConfigureAwait(false);
+
+ if (assignment == null || assignment.Length == 0)
+ {
+ // Happens on table drop.
+ return default;
+ }
+
var partition = Math.Abs(colocationHash % assignment.Length);
var nodeId = assignment[partition];
return PreferredNode.FromId(nodeId);
}
- private async ValueTask<string[]> GetPartitionAssignmentAsync()
+ private async ValueTask<string[]?> GetPartitionAssignmentAsync()
{
var socketVer = _socket.PartitionAssignmentVersion;
var assignment = _partitionAssignment;
@@ -346,7 +353,7 @@ namespace Apache.Ignite.Internal.Table
/// Loads the partition assignment.
/// </summary>
/// <returns>Partition assignment.</returns>
- private async Task<string[]> LoadPartitionAssignmentAsync()
+ private async Task<string[]?> LoadPartitionAssignmentAsync()
{
using var writer = ProtoCommon.GetMessageWriter();
writer.MessageWriter.Write(Id);
@@ -354,10 +361,16 @@ namespace Apache.Ignite.Internal.Table
using var resBuf = await
_socket.DoOutInOpAsync(ClientOp.PartitionAssignmentGet,
writer).ConfigureAwait(false);
return Read();
- string[] Read()
+ string[]? Read()
{
var r = resBuf.GetReader();
var count = r.ReadArrayHeader();
+
+ if (count == 0)
+ {
+ return null;
+ }
+
var res = new string[count];
for (int i = 0; i < count; i++)