Skip to content
New issue

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

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

Already on GitHub? # to your account

Error when creating several users in a row using driver v2 #619

Open
vfouqueron opened this issue Aug 19, 2024 · 7 comments
Open

Error when creating several users in a row using driver v2 #619

vfouqueron opened this issue Aug 19, 2024 · 7 comments

Comments

@vfouqueron
Copy link

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

@jwierzbo
Copy link
Collaborator

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

@vfouqueron
Copy link
Author

vfouqueron commented Sep 24, 2024

@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

@jwierzbo
Copy link
Collaborator

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

@vfouqueron
Copy link
Author

@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.

@kb-sp
Copy link

kb-sp commented Sep 27, 2024

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...)
}

@jwierzbo
Copy link
Collaborator

jwierzbo commented Oct 2, 2024

@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.

@vfouqueron
Copy link
Author

@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.

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

No branches or pull requests

3 participants