This is an automated email from the ASF dual-hosted git repository.

eerhardt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new efd7c3a0b2 ARROW-16978: [C#] Intermittent Archery Failures (#13573)
efd7c3a0b2 is described below

commit efd7c3a0b2a6ec9c87f80ab4120702364e531369
Author: Eric Erhardt <[email protected]>
AuthorDate: Mon Jul 11 21:04:35 2022 -0600

    ARROW-16978: [C#] Intermittent Archery Failures (#13573)
    
    RentReturnAsync has a bug where the rented byte[] is getting returned to 
the pool while the async action is still using it. This causes intermittent 
failures due to the pooled array's data being overwritten while it is still 
used.
    
    To fix the issue, we need to await the async action and only return the 
rented array back to the pool once the async action is complete.
    
    Authored-by: Eric Erhardt <[email protected]>
    Signed-off-by: Eric Erhardt <[email protected]>
---
 csharp/src/Apache.Arrow/Extensions/ArrayPoolExtensions.cs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/csharp/src/Apache.Arrow/Extensions/ArrayPoolExtensions.cs 
b/csharp/src/Apache.Arrow/Extensions/ArrayPoolExtensions.cs
index 9dd9589c03..95a39439f7 100644
--- a/csharp/src/Apache.Arrow/Extensions/ArrayPoolExtensions.cs
+++ b/csharp/src/Apache.Arrow/Extensions/ArrayPoolExtensions.cs
@@ -42,14 +42,14 @@ namespace Apache.Arrow
         }
 
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        public static ValueTask RentReturnAsync(this ArrayPool<byte> pool, int 
length, Func<Memory<byte>, ValueTask> action)
+        public static async ValueTask RentReturnAsync(this ArrayPool<byte> 
pool, int length, Func<Memory<byte>, ValueTask> action)
         {
             byte[] array = null;
 
             try
             {
                 array = pool.Rent(length);
-                return action(array.AsMemory(0, length));
+                await action(array.AsMemory(0, length));
             }
             finally
             {

Reply via email to