-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix an issue AWS Redshift auto-provisioned user not deleted in drop mode #36828
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,8 +3,11 @@ LANGUAGE plpgsql | |||||||||||
| AS $$ | ||||||||||||
| BEGIN | ||||||||||||
| -- Only drop if the user doesn't have other active sessions. | ||||||||||||
| IF EXISTS (SELECT usename FROM pg_stat_activity WHERE usename = username) THEN | ||||||||||||
| RAISE NOTICE 'User has active connections'; | ||||||||||||
| -- Update to pg_stat_activity is delayed for a few hundred ms. Use | ||||||||||||
| -- stv_sessions instead: | ||||||||||||
| -- https://docs.aws.amazon.com/redshift/latest/dg/r_STV_SESSIONS.html | ||||||||||||
| IF EXISTS (SELECT user_name FROM stv_sessions WHERE user_name = CONCAT('IAM:', username)) THEN | ||||||||||||
| RAISE EXCEPTION 'TP000: User has active connections'; | ||||||||||||
|
Comment on lines
+9
to
+10
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copied from: teleport/lib/srv/db/postgres/sql/redshift-deactivate-user.sql Lines 7 to 11 in 8815257
Note the bug happens because |
||||||||||||
| ELSE | ||||||||||||
| BEGIN | ||||||||||||
| EXECUTE 'DROP USER ' || QUOTE_IDENT(username); | ||||||||||||
|
|
||||||||||||
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.
Nit: Maybe include a link to https://docs.aws.amazon.com/redshift/latest/dg/r_STV_SESSIONS.html that explains what this table is? I had to look it up.