- Notifications
You must be signed in to change notification settings - Fork5
Commitf337658
committed
Fix locking a tuple updated by an aborted (sub)transaction
When heap_lock_tuple decides to follow the update chain, it tried toalso lock any version of the tuple that was created by an update thatwas subsequently rolled back. This is pointless, since for all intentsand purposes that tuple exists no more; and moreover it causesmisbehavior, as reported independently by Marko Tiikkaja and MartiRaudsepp: some SELECT FOR UPDATE/SHARE queries may fail to returnthe tuples, and assertion-enabled builds crash.Fix by having heap_lock_updated_tuple test the xmin and return successimmediately if the tuple was created by an aborted transaction.The condition where tuples become invisible occurs when an updated tuplechain is followed by heap_lock_updated_tuple, which reports the problemas HeapTupleSelfUpdated to its caller heap_lock_tuple, which in turnpropagates that code outwards possibly leading the calling code(ExecLockRows) to believe that the tuple exists no longer.Backpatch to 9.3. Only on 9.5 and newer this leads to a visiblefailure, because of commit27846f0; before that, heap_lock_tupleskips the whole dance when the tuple is already locked by the sametransaction, because of the ancient HeapTupleSatisfiesUpdate behavior.Still, the buggy condition may also exist in more convoluted scenariosinvolving concurrent transactions, so it seems safer to fix the bug inthe old branches too.Discussion:https://www.postgresql.org/message-id/CABRT9RC81YUf1=jsmWopcKJEro=VoeG2ou6sPwyOUTx_qteRsg@mail.gmail.comhttps://www.postgresql.org/message-id/48d3eade-98d3-8b9a-477e-1a8dc32a724d@joh.to1 parentf3b3e87 commitf337658
File tree
3 files changed
+56
-0
lines changed- src
- backend/access/heap
- test/regress
- expected
- sql
3 files changed
+56
-0
lines changedLines changed: 11 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5403 | 5403 |
| |
5404 | 5404 |
| |
5405 | 5405 |
| |
| 5406 | + | |
| 5407 | + | |
| 5408 | + | |
| 5409 | + | |
| 5410 | + | |
| 5411 | + | |
| 5412 | + | |
| 5413 | + | |
| 5414 | + | |
| 5415 | + | |
| 5416 | + | |
5406 | 5417 |
| |
5407 | 5418 |
| |
5408 | 5419 |
| |
|
Lines changed: 27 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
140 | 140 |
| |
141 | 141 |
| |
142 | 142 |
| |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + |
Lines changed: 18 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
91 | 91 |
| |
92 | 92 |
| |
93 | 93 |
| |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + |
0 commit comments
Comments
(0)