forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit649dd1b
committed
Avoid serializability errors when locking a tuple with a committed update
When key-share locking a tuple that has been not-key-updated, and theupdate is a committed transaction, in some cases we raisedserializability errors: ERROR: could not serialize access due to concurrent updateBecause the key-share doesn't conflict with the update, the error isunnecessary and inconsistent with the case that the update hasn'tcommitted yet. This causes problems for some usage patterns, even if itcan be claimed that it's sufficient to retry the aborted transaction:given a steady stream of updating transactions and a long lockingtransaction, the long transaction can be starved indefinitely despitemultiple retries.To fix, we recognize that HeapTupleSatisfiesUpdate can returnHeapTupleUpdated when an updating transaction has committed, and that weneed to deal with that case exactly as if it were a non-committedupdate: verify whether the two operations conflict, and if not, carry onnormally. If they do conflict, however, there is a difference: in theHeapTupleBeingUpdated case we can just sleep until the concurrenttransaction is gone, while in the HeapTupleUpdated case this is notpossible and we must raise an error instead.Per trouble report from Olivier Dony.In addition to a couple of test cases that verify the changed behavior,I added a test case to verify the behavior that remains unchanged,namely that errors are raised when a update that modifies the key isused. That must still generate serializability errors. Onepre-existing test case changes behavior; per discussion, the newbehavior is actually the desired one.Discussion:https://www.postgresql.org/message-id/560AA479.4080807@odoo.comhttps://www.postgresql.org/message-id/20151014164844.3019.25750@wrigleys.postgresql.orgBackpatch to 9.3, where the problem appeared.1 parent3246135 commit649dd1b
File tree
9 files changed
+1401
-4
lines changed- src
- backend/access/heap
- test/isolation
- expected
- specs
9 files changed
+1401
-4
lines changedLines changed: 13 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4317 | 4317 |
| |
4318 | 4318 |
| |
4319 | 4319 |
| |
4320 |
| - | |
| 4320 | + | |
4321 | 4321 |
| |
4322 | 4322 |
| |
4323 | 4323 |
| |
| |||
4577 | 4577 |
| |
4578 | 4578 |
| |
4579 | 4579 |
| |
| 4580 | + | |
| 4581 | + | |
| 4582 | + | |
| 4583 | + | |
| 4584 | + | |
| 4585 | + | |
4580 | 4586 |
| |
4581 | 4587 |
| |
4582 | 4588 |
| |
4583 | 4589 |
| |
4584 |
| - | |
4585 |
| - | |
| 4590 | + | |
| 4591 | + | |
| 4592 | + | |
| 4593 | + | |
| 4594 | + | |
| 4595 | + | |
4586 | 4596 |
| |
4587 | 4597 |
| |
4588 | 4598 |
| |
|
0 commit comments
Comments
(0)