forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit216a784

Amit Kapila
Perform apply of large transactions by parallel workers.
Currently, for large transactions, the publisher sends the data inmultiple streams (changes divided into chunks depending uponlogical_decoding_work_mem), and then on the subscriber-side, the applyworker writes the changes into temporary files and once it receives thecommit, it reads from those files and applies the entire transaction. Toimprove the performance of such transactions, we can instead allow them tobe applied via parallel workers.In this approach, we assign a new parallel apply worker (if available) assoon as the xact's first stream is received and the leader apply workerwill send changes to this new worker via shared memory. The parallel applyworker will directly apply the change instead of writing it to temporaryfiles. However, if the leader apply worker times out while attempting tosend a message to the parallel apply worker, it will switch to"partial serialize" mode - in this mode, the leader serializes allremaining changes to a file and notifies the parallel apply workers toread and apply them at the end of the transaction. We use a non-blockingway to send the messages from the leader apply worker to the parallelapply to avoid deadlocks. We keep this parallel apply assigned till thetransaction commit is received and also wait for the worker to finish atcommit. This preserves commit ordering and avoid writing to and readingfrom files in most cases. We still need to spill if there is no workeravailable.This patch also extends the SUBSCRIPTION 'streaming' parameter so that theuser can control whether to apply the streaming transaction in a parallelapply worker or spill the change to disk. The user can set the streamingparameter to 'on/off', or 'parallel'. The parameter value 'parallel' meansthe streaming will be applied via a parallel apply worker, if available.The parameter value 'on' means the streaming transaction will be spilledto disk. The default value is 'off' (same as current behaviour).In addition, the patch extends the logical replication STREAM_ABORTmessage so that abort_lsn and abort_time can also be sent which can beused to update the replication origin in parallel apply worker when thestreaming transaction is aborted. Because this message extension is neededto support parallel streaming, parallel streaming is not supported forpublications on servers < PG16.Author: Hou Zhijie, Wang wei, Amit Kapila with design inputs from Sawada MasahikoReviewed-by: Sawada Masahiko, Peter Smith, Dilip Kumar, Shi yu, Kuroda Hayato, Shveta MallikDiscussion:https://postgr.es/m/CAA4eK1+wyN6zpaHUkCLorEWNx75MG0xhMwcFhvjqm2KURZEAGw@mail.gmail.com1 parent5687e78 commit216a784
File tree
58 files changed
+4511
-759
lines changed- doc/src/sgml
- ref
- src
- backend
- access/transam
- commands
- libpq
- postmaster
- replication
- libpqwalreceiver
- logical
- pgoutput
- storage
- ipc
- lmgr
- tcop
- utils
- activity
- adt
- misc
- bin
- pg_dump
- psql
- include
- catalog
- commands
- replication
- storage
- utils
- test
- regress
- expected
- sql
- subscription/t
- tools/pgindent
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
58 files changed
+4511
-759
lines changedLines changed: 8 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7913 | 7913 |
| |
7914 | 7914 |
| |
7915 | 7915 |
| |
7916 |
| - | |
| 7916 | + | |
7917 | 7917 |
| |
7918 | 7918 |
| |
7919 |
| - | |
7920 |
| - | |
| 7919 | + | |
| 7920 | + | |
| 7921 | + | |
| 7922 | + | |
| 7923 | + | |
| 7924 | + | |
| 7925 | + | |
7921 | 7926 |
| |
7922 | 7927 |
| |
7923 | 7928 |
| |
|
Lines changed: 27 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4968 | 4968 |
| |
4969 | 4969 |
| |
4970 | 4970 |
| |
4971 |
| - | |
| 4971 | + | |
| 4972 | + | |
4972 | 4973 |
| |
4973 | 4974 |
| |
4974 | 4975 |
| |
| |||
5008 | 5009 |
| |
5009 | 5010 |
| |
5010 | 5011 |
| |
| 5012 | + | |
| 5013 | + | |
| 5014 | + | |
| 5015 | + | |
| 5016 | + | |
| 5017 | + | |
| 5018 | + | |
| 5019 | + | |
| 5020 | + | |
| 5021 | + | |
| 5022 | + | |
| 5023 | + | |
| 5024 | + | |
| 5025 | + | |
| 5026 | + | |
| 5027 | + | |
| 5028 | + | |
| 5029 | + | |
| 5030 | + | |
| 5031 | + | |
| 5032 | + | |
| 5033 | + | |
| 5034 | + | |
| 5035 | + | |
| 5036 | + | |
5011 | 5037 |
| |
5012 | 5038 |
| |
5013 | 5039 |
| |
|
Lines changed: 20 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1501 | 1501 |
| |
1502 | 1502 |
| |
1503 | 1503 |
| |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
1504 | 1514 |
| |
1505 | 1515 |
| |
1506 | 1516 |
| |
| |||
1809 | 1819 |
| |
1810 | 1820 |
| |
1811 | 1821 |
| |
1812 |
| - | |
1813 |
| - | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
1814 | 1825 |
| |
1815 | 1826 |
| |
1816 | 1827 |
| |
| |||
1827 | 1838 |
| |
1828 | 1839 |
| |
1829 | 1840 |
| |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
1830 | 1848 |
| |
1831 | 1849 |
| |
1832 | 1850 |
| |
|
Lines changed: 5 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1858 | 1858 |
| |
1859 | 1859 |
| |
1860 | 1860 |
| |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
1861 | 1866 |
| |
1862 | 1867 |
| |
1863 | 1868 |
| |
|
Lines changed: 28 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3103 | 3103 |
| |
3104 | 3104 |
| |
3105 | 3105 |
| |
3106 |
| - | |
| 3106 | + | |
3107 | 3107 |
| |
3108 | 3108 |
| |
3109 | 3109 |
| |
| |||
3113 | 3113 |
| |
3114 | 3114 |
| |
3115 | 3115 |
| |
| 3116 | + | |
| 3117 | + | |
| 3118 | + | |
| 3119 | + | |
| 3120 | + | |
3116 | 3121 |
| |
3117 | 3122 |
| |
3118 | 3123 |
| |
| |||
6883 | 6888 |
| |
6884 | 6889 |
| |
6885 | 6890 |
| |
| 6891 | + | |
| 6892 | + | |
| 6893 | + | |
| 6894 | + | |
| 6895 | + | |
| 6896 | + | |
| 6897 | + | |
| 6898 | + | |
| 6899 | + | |
| 6900 | + | |
| 6901 | + | |
| 6902 | + | |
| 6903 | + | |
| 6904 | + | |
| 6905 | + | |
| 6906 | + | |
| 6907 | + | |
| 6908 | + | |
| 6909 | + | |
| 6910 | + | |
| 6911 | + | |
| 6912 | + | |
6886 | 6913 |
| |
6887 | 6914 |
| |
6888 | 6915 |
| |
|
Lines changed: 20 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
228 | 228 |
| |
229 | 229 |
| |
230 | 230 |
| |
231 |
| - | |
| 231 | + | |
232 | 232 |
| |
233 | 233 |
| |
234 | 234 |
| |
235 |
| - | |
236 |
| - | |
237 |
| - | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
238 | 254 |
| |
239 | 255 |
| |
240 | 256 |
| |
|
Lines changed: 12 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1379 | 1379 |
| |
1380 | 1380 |
| |
1381 | 1381 |
| |
1382 |
| - | |
1383 |
| - | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
1384 | 1385 |
| |
1385 | 1386 |
| |
1386 | 1387 |
| |
| |||
1594 | 1595 |
| |
1595 | 1596 |
| |
1596 | 1597 |
| |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
1597 | 1607 |
| |
1598 | 1608 |
| |
1599 | 1609 |
| |
|
Lines changed: 18 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1713 | 1713 |
| |
1714 | 1714 |
| |
1715 | 1715 |
| |
| 1716 | + | |
1716 | 1717 |
| |
1717 | 1718 |
| |
1718 | 1719 |
| |
| |||
1743 | 1744 |
| |
1744 | 1745 |
| |
1745 | 1746 |
| |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
| 1753 | + | |
1746 | 1754 |
| |
1747 | 1755 |
| |
1748 | 1756 |
| |
| |||
1766 | 1774 |
| |
1767 | 1775 |
| |
1768 | 1776 |
| |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
1769 | 1782 |
| |
1770 | 1783 |
| |
1771 | 1784 |
| |
| |||
5873 | 5886 |
| |
5874 | 5887 |
| |
5875 | 5888 |
| |
5876 |
| - | |
5877 |
| - | |
| 5889 | + | |
| 5890 | + | |
5878 | 5891 |
| |
5879 |
| - | |
5880 |
| - | |
| 5892 | + | |
5881 | 5893 |
| |
5882 | 5894 |
| |
5883 | 5895 |
| |
| |||
5934 | 5946 |
| |
5935 | 5947 |
| |
5936 | 5948 |
| |
5937 |
| - | |
5938 |
| - | |
| 5949 | + | |
| 5950 | + | |
5939 | 5951 |
| |
5940 | 5952 |
| |
5941 | 5953 |
| |
|
Lines changed: 62 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
85 | 85 |
| |
86 | 86 |
| |
87 | 87 |
| |
88 |
| - | |
| 88 | + | |
89 | 89 |
| |
90 | 90 |
| |
91 | 91 |
| |
| |||
139 | 139 |
| |
140 | 140 |
| |
141 | 141 |
| |
142 |
| - | |
| 142 | + | |
143 | 143 |
| |
144 | 144 |
| |
145 | 145 |
| |
| |||
242 | 242 |
| |
243 | 243 |
| |
244 | 244 |
| |
245 |
| - | |
| 245 | + | |
246 | 246 |
| |
247 | 247 |
| |
248 | 248 |
| |
| |||
630 | 630 |
| |
631 | 631 |
| |
632 | 632 |
| |
633 |
| - | |
| 633 | + | |
634 | 634 |
| |
635 | 635 |
| |
636 | 636 |
| |
| |||
1099 | 1099 |
| |
1100 | 1100 |
| |
1101 | 1101 |
| |
1102 |
| - | |
| 1102 | + | |
1103 | 1103 |
| |
1104 | 1104 |
| |
1105 | 1105 |
| |
| |||
2128 | 2128 |
| |
2129 | 2129 |
| |
2130 | 2130 |
| |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
| 2135 | + | |
| 2136 | + | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
| 2141 | + | |
| 2142 | + | |
| 2143 | + | |
| 2144 | + | |
| 2145 | + | |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
| 2151 | + | |
| 2152 | + | |
| 2153 | + | |
| 2154 | + | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + |
0 commit comments
Comments
(0)