forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit1b5d797
committed
Lower lock level for renaming indexes
Change lock level for renaming index (either ALTER INDEX or implicitlyvia some other commands) from AccessExclusiveLock toShareUpdateExclusiveLock.One reason we need a strong lock for relation renaming is that thename change causes a rebuild of the relcache entry. Concurrentsessions that have the relation open might not be able to handle therelcache entry changing underneath them. Therefore, we need to lockthe relation in a way that no one can have the relation openconcurrently. But for indexes, the relcache handles reloads speciallyin RelationReloadIndexInfo() in a way that keeps changes in therelcache entry to a minimum. As long as no one keeps pointers tord_amcache and rd_options around across possible relcache flushes,which is the case, this ought to be safe.We also want to use a self-exclusive lock for correctness, so thatconcurrent DDL doesn't overwrite the rename if they start updatingwhile still seeing the old version. Therefore, we useShareUpdateExclusiveLock, which is already used by other DDL commandsthat want to operate in a concurrent manner.The reason this is interesting at all is that renaming an index is atypical part of a concurrent reindexing workflow (CREATE INDEXCONCURRENTLY new + DROP INDEX CONCURRENTLY old + rename back). Andindeed a future built-in REINDEX CONCURRENTLY might rely on the abilityto do concurrent renames as well.Reviewed-by: Andrey Klychkov <aaklychkov@mail.ru>Reviewed-by: Fabrízio de Royes Mello <fabriziomello@gmail.com>Discussion:https://www.postgresql.org/message-id/flat/1531767486.432607658@f357.i.mail.ru1 parentb4721f3 commit1b5d797
File tree
6 files changed
+36
-21
lines changed- doc/src/sgml
- ref
- src
- backend/commands
- include/commands
6 files changed
+36
-21
lines changedLines changed: 6 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
926 | 926 |
| |
927 | 927 |
| |
928 | 928 |
| |
929 |
| - | |
930 |
| - | |
931 |
| - | |
932 |
| - | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
933 | 933 |
| |
934 | 934 |
| |
935 | 935 |
| |
| |||
970 | 970 |
| |
971 | 971 |
| |
972 | 972 |
| |
973 |
| - | |
| 973 | + | |
974 | 974 |
| |
975 | 975 |
| |
976 | 976 |
| |
| |||
1020 | 1020 |
| |
1021 | 1021 |
| |
1022 | 1022 |
| |
1023 |
| - | |
| 1023 | + | |
1024 | 1024 |
| |
1025 | 1025 |
| |
1026 | 1026 |
| |
|
Lines changed: 8 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
39 | 39 |
| |
40 | 40 |
| |
41 | 41 |
| |
42 |
| - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
43 | 46 |
| |
44 | 47 |
| |
45 | 48 |
| |
| |||
53 | 56 |
| |
54 | 57 |
| |
55 | 58 |
| |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
56 | 63 |
| |
57 | 64 |
| |
58 | 65 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1661 | 1661 |
| |
1662 | 1662 |
| |
1663 | 1663 |
| |
1664 |
| - | |
| 1664 | + | |
1665 | 1665 |
| |
1666 | 1666 |
| |
1667 | 1667 |
| |
1668 | 1668 |
| |
1669 | 1669 |
| |
1670 | 1670 |
| |
1671 |
| - | |
| 1671 | + | |
1672 | 1672 |
| |
1673 | 1673 |
| |
1674 | 1674 |
| |
|
Lines changed: 17 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3044 | 3044 |
| |
3045 | 3045 |
| |
3046 | 3046 |
| |
3047 |
| - | |
| 3047 | + | |
3048 | 3048 |
| |
3049 | 3049 |
| |
3050 | 3050 |
| |
| |||
3112 | 3112 |
| |
3113 | 3113 |
| |
3114 | 3114 |
| |
| 3115 | + | |
3115 | 3116 |
| |
3116 | 3117 |
| |
3117 | 3118 |
| |
| |||
3123 | 3124 |
| |
3124 | 3125 |
| |
3125 | 3126 |
| |
3126 |
| - | |
| 3127 | + | |
| 3128 | + | |
3127 | 3129 |
| |
3128 | 3130 |
| |
3129 | 3131 |
| |
| |||
3137 | 3139 |
| |
3138 | 3140 |
| |
3139 | 3141 |
| |
3140 |
| - | |
| 3142 | + | |
3141 | 3143 |
| |
3142 | 3144 |
| |
3143 | 3145 |
| |
| |||
3148 | 3150 |
| |
3149 | 3151 |
| |
3150 | 3152 |
| |
3151 |
| - | |
| 3153 | + | |
3152 | 3154 |
| |
3153 | 3155 |
| |
3154 | 3156 |
| |
| |||
3157 | 3159 |
| |
3158 | 3160 |
| |
3159 | 3161 |
| |
3160 |
| - | |
3161 |
| - | |
3162 |
| - | |
| 3162 | + | |
| 3163 | + | |
| 3164 | + | |
| 3165 | + | |
| 3166 | + | |
| 3167 | + | |
| 3168 | + | |
| 3169 | + | |
3163 | 3170 |
| |
3164 |
| - | |
| 3171 | + | |
3165 | 3172 |
| |
3166 | 3173 |
| |
3167 | 3174 |
| |
| |||
3214 | 3221 |
| |
3215 | 3222 |
| |
3216 | 3223 |
| |
3217 |
| - | |
| 3224 | + | |
3218 | 3225 |
| |
3219 | 3226 |
| |
3220 | 3227 |
| |
| |||
7076 | 7083 |
| |
7077 | 7084 |
| |
7078 | 7085 |
| |
7079 |
| - | |
| 7086 | + | |
7080 | 7087 |
| |
7081 | 7088 |
| |
7082 | 7089 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3255 | 3255 |
| |
3256 | 3256 |
| |
3257 | 3257 |
| |
3258 |
| - | |
| 3258 | + | |
3259 | 3259 |
| |
3260 | 3260 |
| |
3261 | 3261 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
67 | 67 |
| |
68 | 68 |
| |
69 | 69 |
| |
70 |
| - | |
| 70 | + | |
| 71 | + | |
71 | 72 |
| |
72 | 73 |
| |
73 | 74 |
| |
|
0 commit comments
Comments
(0)