go-driver icon indicating copy to clipboard operation
go-driver copied to clipboard

Error when creating several users in a row using driver v2

Open vfouqueron opened this issue 1 year ago • 7 comments

Hello, I'm trying to create several arangodb users using the api. Sometimes, I have the error : HTTP Error: user not found

The user is actually created but I cannot be sure of it

vfouqueron avatar Aug 19 '24 12:08 vfouqueron

@vfouqueron Did this happen during the user creation request, or later when you tried to check if the created user exists?

jwierzbo avatar Sep 17 '24 13:09 jwierzbo

@vfouqueron Did this happen during the user creation request, or later when you tried to check if the created user exists?

It was on creation, the user is created but it returns this error, which makes no sense in this case

vfouqueron avatar Sep 24 '24 14:09 vfouqueron

@vfouqueron do you have any code to reproduce it? We have a IT tests for user creation within the test scope.

jwierzbo avatar Sep 24 '24 14:09 jwierzbo

@jwierzbo Yes, I have the issue in this code : https://github.com/predell/terraform-provider-arangodb/blob/main/internal/provider/user_resource.go

Precisely, I have that:

_, err := r.client.CreateUser(ctx, data.User.ValueString(), toUserOptions(data))
if err != nil && !shared.IsConflict(err) {
  resp.Diagnostics.AddError(
	  "Unable to Create User "+
		  data.User.ValueString(),
	  "An unexpected error occurred while attempting to create the resource. "+
		  "Please retry the operation or report this issue to the provider developers.\n\n"+
		  "HTTP Error: "+err.Error(),
  )

There is nothing incredible and I iterated over just five users in parallel.

I don't know if you need me to code a more precise and reproductible use case. I'm not on the subject currently and not a go expert, so I'll need a little bit of time to create a concise and reproductible case.

Other precision, I ran that on an Arango cluster running inside a Kubernetes cluster.

vfouqueron avatar Sep 24 '24 15:09 vfouqueron

Just a fly on the wall here, but this pattern makes me wonder if there are concurrency issues:

func (c *connectionPool) NewRequest(method string, urls ...string) (Request, error) {
	return c.connections[0].NewRequest(method, urls...)
}

kb-sp avatar Sep 27 '24 18:09 kb-sp

@vfouqueron We found that this is an internal database error, and it cannot be fixed in the go-driver.

For now, until a fix is provided, you can use the following workarounds: 1. Limit the parallelism factor in Terraform (the default is set to 10): terraform apply -parallelism=1 2. Another option is to ignore the user not found error in this specific case, as the user is always created but not returned due to a bug in the coordinator’s code.

jwierzbo avatar Oct 02 '24 13:10 jwierzbo

@jwierzbo Thank you for finding the issue! For our project, we don’t create often new users with that, so it does not block us for the moment. I will probably use the second option as a temporary fix if anyone want to use our provider.

vfouqueron avatar Oct 02 '24 15:10 vfouqueron