fix: Stop locking catalog for every resources. #80
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Historically, this provider takes a (golang) lock on a database for every resource of this database.
So only one create/update/delete of resource by database can be done at the same time.
(As it's a RWLock, read of resources can be parallelized)
Since #5 refactoring, I mistakenly change the lock which now takes a write lock even for read operations
(basically the plan part of Terraform). So provider was slower since v1.10
We could fix this and take a read lock for read operations as before but actually I don't see the point of this lock.
For me, most operations could be done at the same time.
Most of the request are now done in a transaction, the only risk is that a transaction will fail to commit
if multiple resources modifies the same database line.
That's the case for
postgresql_default_privileges
, onepg_default_acl
row could represents multiple resources,so this PR takes a lock on the owner role to avoid that.
This should make the provider way faster.
Tested with this code: https://github.com/cyrilgdn/terraform-provider-postgresql/tree/master/examples/issues/48
Fix #48