Skip to content

x-goog-user-project header when creating multiple buckets in parallel #2968

@AlessandroMartinelli

Description

@AlessandroMartinelli

Environment details

  • OS: Microsoft Windows 11 Pro
  • .NET version: 8
  • Package name and version: Google.Cloud.Storage.V1 4.13.0

Steps to reproduce

  1. In a static class, initialize the StorageClient by
    static readonly StorageClient _storageClient = StorageClient.Create();
  2. In a static method of the above class, define a method like this
    internal static void CreateBucket(string bucketName)
    {
        Console.WriteLine($"Bucket {bucketName} creation in progress");
        lock (_obj) {
            _storageClient.CreateBucket(__PROJECT_ID, new Bucket {
                Name = bucketName,
                Location = __LOCATION,
            });            
        }
       Console.WriteLine($"Bucket {bucketName} created successfully");
    }
  1. Invoke the method from 30 tasks running in parallel.

Issue

When I follow the above procedure, the bucket creation succeed for the first 17 or 18 buckets, then it fails raising the following exception:

System.InvalidOperationException: x-goog-user-project header can only be added through the credential or through the <Product>ClientBuilder.
   at Google.Apis.Http.ConfigurableMessageHandler.CheckValidAfterInterceptors(HttpRequestMessage request)
   at Google.Apis.Http.ConfigurableMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
   at Google.Apis.Requests.ClientServiceRequest`1.ExecuteUnparsedAsync(CancellationToken cancellationToken)
   at Google.Apis.Requests.ClientServiceRequest`1.Execute()
   at Google.Cloud.Storage.V1.StorageClientImpl.CreateBucket(String projectId, Bucket bucket, CreateBucketOptions options)

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions