forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitdafaa3e
committed
Implement genuine serializable isolation level.
Until now, our Serializable mode has in fact been what's called SnapshotIsolation, which allows some anomalies that could not occur in anyserialized ordering of the transactions. This patch fixes that using amethod called Serializable Snapshot Isolation, based on research papers byMichael J. Cahill (see README-SSI for full references). In SerializableSnapshot Isolation, transactions run like they do in Snapshot Isolation,but a predicate lock manager observes the reads and writes performed andaborts transactions if it detects that an anomaly might occur. This methodproduces some false positives, ie. it sometimes aborts transactions eventhough there is no anomaly.To track reads we implement predicate locking, see storage/lmgr/predicate.c.Whenever a tuple is read, a predicate lock is acquired on the tuple. Sharedmemory is finite, so when a transaction takes many tuple-level locks on apage, the locks are promoted to a single page-level lock, and further to asingle relation level lock if necessary. To lock key values with no matchingtuple, a sequential scan always takes a relation-level lock, and an indexscan acquires a page-level lock that covers the search key, whether or notthere are any matching keys at the moment.A predicate lock doesn't conflict with any regular locks or with anotherpredicate locks in the normal sense. They're only used by the predicate lockmanager to detect the danger of anomalies. Only serializable transactionsparticipate in predicate locking, so there should be no extra overhead forfor other transactions.Predicate locks can't be released at commit, but must be remembered untilall the transactions that overlapped with it have completed. That means thatwe need to remember an unbounded amount of predicate locks, so we apply alossy but conservative method of tracking locks for committed transactions.If we run short of shared memory, we overflow to a new "pg_serial" SLRUpool.We don't currently allow Serializable transactions in Hot Standby mode.That would be hard, because even read-only transactions can cause anomaliesthat wouldn't otherwise occur.Serializable isolation mode now means the new fully serializable level.Repeatable Read gives you the old Snapshot Isolation level that we havealways had.Kevin Grittner and Dan Ports, reviewed by Jeff Davis, Heikki Linnakangas andAnssi Kääriäinen1 parentc18f51d commitdafaa3e
File tree
90 files changed
+14994
-270
lines changed- doc/src/sgml
- ref
- src
- backend
- access
- heap
- index
- nbtree
- transam
- commands
- executor
- parser
- storage
- ipc
- lmgr
- tcop
- utils
- adt
- misc
- resowner
- time
- bin
- initdb
- pg_dump
- include
- access
- catalog
- commands
- storage
- test
- isolation
- expected
- specs
- regress
- expected
- sql
- tools/pgindent
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
90 files changed
+14994
-270
lines changedLines changed: 8 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
490 | 490 |
| |
491 | 491 |
| |
492 | 492 |
| |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
493 | 500 |
| |
494 | 501 |
| |
495 | 502 |
| |
| |||
6577 | 6584 |
| |
6578 | 6585 |
| |
6579 | 6586 |
| |
6580 |
| - | |
| 6587 | + | |
6581 | 6588 |
| |
6582 | 6589 |
| |
6583 | 6590 |
| |
|
Lines changed: 70 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4456 | 4456 |
| |
4457 | 4457 |
| |
4458 | 4458 |
| |
| 4459 | + | |
4459 | 4460 |
| |
4460 | 4461 |
| |
4461 | 4462 |
| |
| |||
4481 | 4482 |
| |
4482 | 4483 |
| |
4483 | 4484 |
| |
| 4485 | + | |
4484 | 4486 |
| |
4485 | 4487 |
| |
4486 | 4488 |
| |
| |||
4500 | 4502 |
| |
4501 | 4503 |
| |
4502 | 4504 |
| |
| 4505 | + | |
| 4506 | + | |
| 4507 | + | |
| 4508 | + | |
| 4509 | + | |
| 4510 | + | |
| 4511 | + | |
| 4512 | + | |
| 4513 | + | |
| 4514 | + | |
| 4515 | + | |
| 4516 | + | |
| 4517 | + | |
| 4518 | + | |
| 4519 | + | |
| 4520 | + | |
| 4521 | + | |
| 4522 | + | |
| 4523 | + | |
| 4524 | + | |
| 4525 | + | |
| 4526 | + | |
| 4527 | + | |
| 4528 | + | |
| 4529 | + | |
| 4530 | + | |
| 4531 | + | |
| 4532 | + | |
| 4533 | + | |
| 4534 | + | |
| 4535 | + | |
| 4536 | + | |
| 4537 | + | |
| 4538 | + | |
| 4539 | + | |
4503 | 4540 |
| |
4504 | 4541 |
| |
4505 | 4542 |
| |
| |||
5125 | 5162 |
| |
5126 | 5163 |
| |
5127 | 5164 |
| |
| 5165 | + | |
| 5166 | + | |
| 5167 | + | |
| 5168 | + | |
| 5169 | + | |
| 5170 | + | |
| 5171 | + | |
| 5172 | + | |
| 5173 | + | |
| 5174 | + | |
| 5175 | + | |
| 5176 | + | |
| 5177 | + | |
| 5178 | + | |
| 5179 | + | |
| 5180 | + | |
| 5181 | + | |
| 5182 | + | |
| 5183 | + | |
| 5184 | + | |
| 5185 | + | |
| 5186 | + | |
| 5187 | + | |
| 5188 | + | |
| 5189 | + | |
| 5190 | + | |
| 5191 | + | |
| 5192 | + | |
| 5193 | + | |
| 5194 | + | |
| 5195 | + | |
| 5196 | + | |
| 5197 | + | |
5128 | 5198 |
| |
5129 | 5199 |
| |
5130 | 5200 |
| |
|
Lines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1916 | 1916 |
| |
1917 | 1917 |
| |
1918 | 1918 |
| |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
1919 | 1928 |
| |
1920 | 1929 |
| |
1921 | 1930 |
| |
|
Lines changed: 13 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
705 | 705 |
| |
706 | 706 |
| |
707 | 707 |
| |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
708 | 721 |
| |
709 | 722 |
| |
710 | 723 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
256 | 256 |
| |
257 | 257 |
| |
258 | 258 |
| |
259 |
| - | |
| 259 | + | |
260 | 260 |
| |
261 | 261 |
| |
262 | 262 |
| |
|
0 commit comments
Comments
(0)