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

Amit Kapila
Allow multiple xacts during table sync in logical replication.
For the initial table data synchronization in logical replication, we usea single transaction to copy the entire table and then synchronize theposition in the stream with the main apply worker.There are multiple downsides of this approach: (a) We have to perform theentire copy operation again if there is any error (network breakdown,error in the database operation, etc.) while we synchronize the WALposition between tablesync worker and apply worker; this will be onerousespecially for large copies, (b) Using a single transaction in thesynchronization-phase (where we can receive WAL from multipletransactions) will have the risk of exceeding the CID limit, (c) The slotwill hold the WAL till the entire sync is complete because we never committill the end.This patch solves all the above downsides by allowing multipletransactions during the tablesync phase. The initial copy is done in asingle transaction and after that, we commit each transaction as wereceive. To allow recovery after any error or crash, we use a permanentslot and origin to track the progress. The slot and origin will be removedonce we finish the synchronization of the table. We also remove slot andorigin of tablesync workers if the user performs DROP SUBSCRIPTION .. orALTER SUBSCRIPTION .. REFERESH and some of the table syncs are still notfinished.The commands ALTER SUBSCRIPTION ... REFRESH PUBLICATION andALTER SUBSCRIPTION ... SET PUBLICATION ... with refresh option as truecannot be executed inside a transaction block because they can now dropthe slots for which we have no provision to rollback.This will also open up the path for logical replication of 2PCtransactions on the subscriber side. Previously, we can't do that becauseof the requirement of maintaining a single transaction in tablesyncworkers.Bump catalog version due to change of state in the catalog(pg_subscription_rel).Author: Peter Smith, Amit Kapila, and Takamichi OsumiReviewed-by: Ajin Cherian, Petr Jelinek, Hou Zhijie and Amit KapilaDiscussion:https://postgr.es/m/CAA4eK1KHJxaZS-fod-0fey=0tq3=Gkn4ho=8N4-5HWiCfu0H1A@mail.gmail.com1 parent3063eb1 commitce0fdbf
File tree
23 files changed
+767
-326
lines changed- doc/src/sgml
- ref
- src
- backend
- access/transam
- catalog
- commands
- replication
- libpqwalreceiver
- logical
- tcop
- include
- catalog
- commands
- replication
- test
- regress
- expected
- sql
- subscription/t
- tools/pgindent
23 files changed
+767
-326
lines changedLines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7673 | 7673 |
| |
7674 | 7674 |
| |
7675 | 7675 |
| |
| 7676 | + | |
7676 | 7677 |
| |
7677 | 7678 |
| |
7678 | 7679 |
| |
|
Lines changed: 37 additions & 22 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
186 | 186 |
| |
187 | 187 |
| |
188 | 188 |
| |
189 |
| - | |
190 |
| - | |
191 |
| - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
192 | 193 |
| |
193 | 194 |
| |
194 | 195 |
| |
| |||
248 | 249 |
| |
249 | 250 |
| |
250 | 251 |
| |
251 |
| - | |
252 |
| - | |
253 |
| - | |
254 |
| - | |
255 |
| - | |
256 |
| - | |
257 |
| - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
258 | 269 |
| |
259 | 270 |
| |
260 | 271 |
| |
| |||
294 | 305 |
| |
295 | 306 |
| |
296 | 307 |
| |
297 |
| - | |
298 |
| - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
299 | 311 |
| |
300 | 312 |
| |
301 | 313 |
| |
| |||
468 | 480 |
| |
469 | 481 |
| |
470 | 482 |
| |
471 |
| - | |
472 |
| - | |
473 |
| - | |
474 |
| - | |
475 |
| - | |
476 |
| - | |
477 |
| - | |
478 |
| - | |
479 |
| - | |
480 |
| - | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
481 | 496 |
| |
482 | 497 |
| |
483 | 498 |
| |
|
Lines changed: 18 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
48 | 48 |
| |
49 | 49 |
| |
50 | 50 |
| |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
51 | 69 |
| |
52 | 70 |
| |
53 | 71 |
| |
|
Lines changed: 4 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
79 | 79 |
| |
80 | 80 |
| |
81 | 81 |
| |
82 |
| - | |
| 82 | + | |
| 83 | + | |
83 | 84 |
| |
84 | 85 |
| |
85 | 86 |
| |
| |||
89 | 90 |
| |
90 | 91 |
| |
91 | 92 |
| |
92 |
| - | |
| 93 | + | |
| 94 | + | |
93 | 95 |
| |
94 | 96 |
| |
95 | 97 |
| |
|
Lines changed: 0 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2432 | 2432 |
| |
2433 | 2433 |
| |
2434 | 2434 |
| |
2435 |
| - | |
2436 |
| - | |
2437 |
| - | |
2438 |
| - | |
2439 |
| - | |
2440 |
| - | |
2441 |
| - | |
2442 |
| - | |
2443 |
| - | |
2444 | 2435 |
| |
2445 | 2436 |
| |
2446 | 2437 |
| |
| |||
4899 | 4890 |
| |
4900 | 4891 |
| |
4901 | 4892 |
| |
4902 |
| - | |
4903 | 4893 |
| |
4904 | 4894 |
| |
4905 | 4895 |
| |
| |||
5059 | 5049 |
| |
5060 | 5050 |
| |
5061 | 5051 |
| |
5062 |
| - | |
5063 | 5052 |
| |
5064 | 5053 |
| |
5065 | 5054 |
| |
|
Lines changed: 38 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
29 | 29 |
| |
30 | 30 |
| |
31 | 31 |
| |
| 32 | + | |
32 | 33 |
| |
33 | 34 |
| |
34 | 35 |
| |
| |||
337 | 338 |
| |
338 | 339 |
| |
339 | 340 |
| |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
340 | 348 |
| |
341 | 349 |
| |
342 | 350 |
| |
| |||
363 | 371 |
| |
364 | 372 |
| |
365 | 373 |
| |
| 374 | + | |
| 375 | + | |
366 | 376 |
| |
367 | 377 |
| |
368 | 378 |
| |
| |||
403 | 413 |
| |
404 | 414 |
| |
405 | 415 |
| |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
406 | 444 |
| |
407 | 445 |
| |
408 | 446 |
| |
|
0 commit comments
Comments
(0)