forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit5c8dabe
committed
Reconsider when to wait for WAL flushes/syncrep during commit.
Up to now RecordTransactionCommit() waited for WAL to be flushed (ifsynchronous_commit != off) and to be synchronously replicated (ifenabled), even if a transaction did not have a xid assigned. The primaryreason for that is that sequence's nextval() did not assign a xid, butare worthwhile to wait for on commit.This can be problematic because sometimes read only transactions dowrite WAL, e.g. HOT page prune records. That then could lead to read onlytransactions having to wait during commit. Not something people expectin a read only transaction.This lead to such strange symptoms as backends being seemingly stuckduring connection establishment when all synchronous replicas aredown. Especially annoying when said stuck connection is the standbytrying to reconnect to allow syncrep again...This behavior also is involved in a rather complicated <= 9.4 bug wherethe transaction started by catchup interrupt processing waited forsyncrep using latches, but didn't get the wakeup because it was alreadyrunning inside the same overloaded signal handler. Fix the issue heredoesn't properly solve that issue, merely papers over the problems. In9.5 catchup interrupts aren't processed out of signal handlers anymore.To fix all this, make nextval() acquire a top level xid, and only wait fortransaction commit if a transaction both acquired a xid and emitted WALrecords. If only a xid has been assigned we don't uselessly want towait just because of writes to temporary/unlogged tables; if only WALhas been written we don't want to wait just because of HOT prunes.The xid assignment in nextval() is unlikely to cause overhead inreal-world workloads. For one it only happens SEQ_LOG_VALS/32 valuesanyway, for another only usage of nextval() without using the result inan insert or similar is affected.Discussion: 20150223165359.GF30784@awork2.anarazel.de, 369698E947874884A77849D8FE3680C2@maumau, 5CF4ABBA67674088B3941894E22A0D25@maumauPer complaint from maumau and Thom BrownBackpatch all the way back; 9.0 doesn't have syncrep, but it seemsbetter to be consistent behavior across all maintained branches.1 parent034d05d commit5c8dabe
2 files changed
+39
-12
lines changedLines changed: 17 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
949 | 949 |
| |
950 | 950 |
| |
951 | 951 |
| |
952 |
| - | |
953 |
| - | |
954 |
| - | |
955 |
| - | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
956 | 955 |
| |
957 | 956 |
| |
958 | 957 |
| |
| |||
1044 | 1043 |
| |
1045 | 1044 |
| |
1046 | 1045 |
| |
1047 |
| - | |
1048 |
| - | |
1049 |
| - | |
1050 |
| - | |
1051 |
| - | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
1052 | 1053 |
| |
1053 | 1054 |
| |
1054 | 1055 |
| |
| |||
1064 | 1065 |
| |
1065 | 1066 |
| |
1066 | 1067 |
| |
1067 |
| - | |
| 1068 | + | |
| 1069 | + | |
1068 | 1070 |
| |
1069 | 1071 |
| |
1070 | 1072 |
| |
| |||
1136 | 1138 |
| |
1137 | 1139 |
| |
1138 | 1140 |
| |
1139 |
| - | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
1140 | 1145 |
| |
1141 | 1146 |
| |
1142 | 1147 |
| |
1143 | 1148 |
| |
1144 |
| - | |
| 1149 | + | |
1145 | 1150 |
| |
1146 | 1151 |
| |
1147 | 1152 |
| |
|
Lines changed: 22 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
343 | 343 |
| |
344 | 344 |
| |
345 | 345 |
| |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
346 | 350 |
| |
347 | 351 |
| |
348 | 352 |
| |
| |||
436 | 440 |
| |
437 | 441 |
| |
438 | 442 |
| |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
439 | 447 |
| |
440 | 448 |
| |
441 | 449 |
| |
| |||
669 | 677 |
| |
670 | 678 |
| |
671 | 679 |
| |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
672 | 690 |
| |
673 | 691 |
| |
674 | 692 |
| |
| |||
863 | 881 |
| |
864 | 882 |
| |
865 | 883 |
| |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
866 | 888 |
| |
867 | 889 |
| |
868 | 890 |
| |
|
0 commit comments
Comments
(0)