forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit98fc31d
committed
Avoid race condition between "GRANT role" and "DROP ROLE".
Concurrently dropping either the granted role or the granteedoes not stop GRANT from completing, instead resulting in adangling role reference in pg_auth_members. That's relativelyharmless in the short run, but inconsistent catalog entriesare not a good thing.This patch solves the problem by adding the granted and granteeroles as explicit shared dependencies of the pg_auth_members entry.That's a bit indirect, but it works because the pg_shdepend codeapplies the necessary locking and rechecking.Commit6566133 previously established similar handling forthe grantor column of pg_auth_members; it's not clear why itdidn't cover the other two role OID columns.A side-effect of this approach is that DROP OWNED BY will now droppg_auth_members entries that mention the target role as either thegranted or grantee role. That's clearly appropriate for thegrantee, since we'll drop its other privileges too. It doesn'tseem too far out of line for the granted role, since we'represumably about to drop it and besides we're removing all reasonswhy it'd matter to be a member of it. (One could argue that thismakes DropRole's code to auto-drop pg_auth_members entriesunnecessary, but I chose to leave it in place since perhaps somepeople's workflows expect that to work without a DROP OWNED BY.)Note to patch readers: CreateRole's first CommandCounterIncrementcall is now unconditional, because this change creates anothercase in which it's needed, and it seemed to be more trouble thanit's worth to preserve that micro-optimization.Arguably this is a bug fix, but the fact that it changes theexpected contents of pg_shdepend seems like not a great thingto do in the stable branches, and perhaps we don't want thechange in DROP OWNED BY semantics there either. On the otherhand, I opted not to force a catversion bump in HEAD, becausethe presence or absence of these entries doesn't matter formost purposes.Reported-by: Virender Singla <virender.cse@gmail.com>Reviewed-by: Laurenz Albe <laurenz.albe@cybertec.at>Discussion:https://postgr.es/m/CAM6Zo8woa62ZFHtMKox6a4jb8qQ=w87R2L0K8347iE-juQL2EA@mail.gmail.com1 parentddb17e3 commit98fc31d
File tree
4 files changed
+63
-7
lines changed- doc/src/sgml/ref
- src
- backend/commands
- test/regress
- expected
- sql
4 files changed
+63
-7
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
33 | 33 |
| |
34 | 34 |
| |
35 | 35 |
| |
36 |
| - | |
| 36 | + | |
37 | 37 |
| |
38 | 38 |
| |
39 | 39 |
| |
|
Lines changed: 17 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
30 | 30 |
| |
31 | 31 |
| |
32 | 32 |
| |
| 33 | + | |
33 | 34 |
| |
34 | 35 |
| |
35 | 36 |
| |
| |||
489 | 490 |
| |
490 | 491 |
| |
491 | 492 |
| |
492 |
| - | |
493 |
| - | |
| 493 | + | |
494 | 494 |
| |
495 | 495 |
| |
496 | 496 |
| |
| |||
1904 | 1904 |
| |
1905 | 1905 |
| |
1906 | 1906 |
| |
1907 |
| - | |
| 1907 | + | |
| 1908 | + | |
1908 | 1909 |
| |
1909 | 1910 |
| |
1910 | 1911 |
| |
| |||
1946 | 1947 |
| |
1947 | 1948 |
| |
1948 | 1949 |
| |
1949 |
| - | |
1950 |
| - | |
| 1950 | + | |
| 1951 | + | |
| 1952 | + | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
| 1957 | + | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
1951 | 1962 |
| |
1952 | 1963 |
| |
1953 | 1964 |
| |
1954 |
| - | |
| 1965 | + | |
1955 | 1966 |
| |
1956 | 1967 |
| |
1957 | 1968 |
| |
|
Lines changed: 30 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
113 | 113 |
| |
114 | 114 |
| |
115 | 115 |
| |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
116 | 146 |
| |
117 | 147 |
| |
118 | 148 |
| |
|
Lines changed: 15 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
90 | 90 |
| |
91 | 91 |
| |
92 | 92 |
| |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
93 | 108 |
| |
94 | 109 |
| |
95 | 110 |
| |
|
0 commit comments
Comments
(0)