-
Notifications
You must be signed in to change notification settings - Fork 200
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
Fix concurrency issue when granting privileges on databases #224
Conversation
Any news on getting this merged? |
@cyrilgdn any chance of this getting merged? |
Hey, any news ? It would be nice to merge it. |
BTW: i think i have workaround for this problem. I have added max_connections = 1 to provider block. Seems to work. Probably it will slow down plans :( |
@BartoszGiza That does work in some cases. Unfortunately that also has another side effect that it can cause the provider to hang indefinitely. |
Hi, I think i just hit that problem. I have problems with hanging during refreshing states. Also for some reason i can't delete database which provider created. |
Hey @cyrilgdn any updates on this ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
Thanks for your work on that, and sorry for the delay.
I had no time to work on opensource projects these past months...
I haven't test it but code looks good so we can ship it 👍
@cyrilgdn thank You |
Will there be a release with this PR included? Thanks. |
Thanks for merging. |
@cyrilgdn when do You plan to release new version ? |
This has been released in v1.18.0 |
I tested 1.18 and am still getting concurrency issues on grants so unfortunately #223 is not fixed |
@philip-harvey Are you sure that you are facing the same issue? |
I am getting errors such as the below when updating grants if I don't have max_connections = 1 │ Error: could not get advisory lock for members of role pdr_ro_rl: pq: deadlock detected |
Can you provide the relevant terraform code? Also the first error: |
This is the specific part of the code that is still failing due to concurrency issues.
AFAIK this issue has existed on all previous and current versions of the provider and the only known way to work around the issue currently is to set max_connections = 1 In this particular use case objects_type = table for most of the grants. Is the merged fix only valid if object_type = database? The exact same issue occurs for tables and schemas as well as databases, and any combination of object_types. e.g. #178 |
This is the most generic code that you could have provided :D Yes this PR only fixes If you want to know which query is actually responsible for your issues you can have a look at the postgres logs. |
I've had to downgrade as this change is causing all sorts of havoc. The biggest one is that its "leaking" advisory locks on databases. I'm often left with multiple locks that I have to manually cleanup. |
Hey @seanamos, I have tested my code again, but I was not able to leak any locks from what I get Do you have an example code to reproduce the issue or could you share the leaked locks here so that I can investigate further? |
Any chance the change in #224 can be rolled back? In the past we could set max_connections = 1 and it would work, now it's just totally broken for versions > 1.1.7 |
Are you able to provide a terraform configuration that has this issue? The fix that I provided might have had some side effects that I am not aware of. |
Changes: v1.21.0 * Make function security, strictness, volatility, and parallel safety configurable * Bump gocloud dependency to fix aws CA validation * Allow for inlining client cert * Use uint32 for OID to stop conversion errors with pguint32 * Postgresql 15 support * Added MS Azure passwordless authentication * Add 'Injecting credentials' section to provider docs * fixed escaping for postgresql user info v1.20.0 As this is my first release for this project, I am keeping the changes to a minimum until I am more comfortable with the release process. * Bump `go` to `1.20` * Bump `lib/pq` to `1.10.9` * Perform `db.Ping()` during database connection to catch issues earlier v1.19.0 No change available. v1.18.0 * New resource: `postgresql_server` and `postgresql_user_mapping` * New resource: `postgresql_subscription` * Allow to configure AWS Region with AWS IAM Auth * Create temporary file for `GOOGLE_APPLICATION_CREDENTIALS` in Terraform cloud * `postgresql_grant`: Concurrency issue on database privileges [#224](cyrilgdn/terraform-provider-postgresql#224) * `postgresql_grant`: Remove `TEMP` privileges for database v1.17.1 * Missing err check that leads to segfault [For other releases no changes are available but mostly new resources and data sources.]
I have tested 1.21.1-beta.1 and concurrency issues are not fixed. The fix provided by giner works. This one not. |
This fixes #223