Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is a problem with descriptor leaks when copying/deleting objects. #1262

Open
sloruslan opened this issue Feb 5, 2025 · 0 comments
Open

Comments

@sloruslan
Copy link

Hello. I wrote a test console application in C# that renames the same file on a Minio server.

My code:

class Program
{
   private static readonly string bucketName = "my-bucket";
   private static readonly IMinioClient minioClient = new MinioClient()
       .WithEndpoint("localhost:9100")  
       .WithCredentials("minioadmin", "minioadmin")
       .Build();

   public static async Task RenameFileAsync(string oldObjectName, string newObjectName, CancellationToken token)
   {
       try
       {
          
           using var cts = CancellationTokenSource.CreateLinkedTokenSource(token);
           cts.CancelAfter(TimeSpan.FromSeconds(30));

           
           var copySourceArgs = new CopySourceObjectArgs()
               .WithBucket(bucketName)
               .WithObject(oldObjectName);

           var copyObjectArgs = new CopyObjectArgs()
               .WithCopyObjectSource(copySourceArgs)
               .WithBucket(bucketName)
               .WithObject(newObjectName);

           await minioClient.CopyObjectAsync(copyObjectArgs, cts.Token);
           Console.WriteLine($"[{DateTime.Now}] Copied {oldObjectName} → {newObjectName}");

          
           var removeObjectArgs = new RemoveObjectArgs()
               .WithBucket(bucketName)
               .WithObject(oldObjectName);

           await minioClient.RemoveObjectAsync(removeObjectArgs, cts.Token);
           Console.WriteLine($"[{DateTime.Now}] Deleted {oldObjectName}");
       }
       catch (Exception ex)
       {
           Console.Error.WriteLine($"Error renaming file: {ex.Message}");
       }
   }

   static async Task Main()
   {
       Console.WriteLine("MinIO Rename Loop Started... Press Ctrl+C to stop.");
       int iteration = 0;
       CancellationTokenSource cts = new CancellationTokenSource();

       
       while (!cts.Token.IsCancellationRequested)
       {
           string oldFileName = $"SGW33_b03266502_{iteration}.dat";
           string newFileName = $"SGW33_b03266502_{iteration+1}.dat";

           await RenameFileAsync(oldFileName, newFileName, cts.Token);

           iteration++;
           await Task.Delay(500, cts.Token); 
       }
   }
}

During the execution of the application, I check the Task Manager and see that the number of descriptors for my application keeps growing endlessly. Screenshot:

Image

In my large application, this causes an unmanaged memory leak. There might be a bug in the implementations of the minioClient.CopyObjectAsync() or minioClient.RemoveObjectAsync() functions, or perhaps I am using them incorrectly?

Please help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant