forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitf731cfa
committed
Fix a couple of bugs with replication slot advancing feature
A review of the code has showed up a couple of issues fixed by thiscommit:- Physical slots have been using the confirmed LSN position as a startcomparison point which is always 0/0, instead use the restart LSNposition (logical slots need to use the confirmed LSN position, whichwas correct).- The actual slot update was incorrect for both physical and logicalslots. Physical slots need to use their restart_lsn as base comparisonpoint (confirmed_flush was used because of previous point), and logicalslots need to begin reading WAL from restart_lsn (confirmed_flush wasused as well), while confirmed_flush is compiled depending on thedecoding context and record read, and is the LSN position returned backto the caller.- Never return 0/0 if a slot cannot be advanced. This way, if a slot isadvanced while the activity is idle, then the same position is returnedto the caller over and over without raising an error. Instead returnthe LSN the slot has been advanced to. With repetitive calls, the sameposition is returned hence caller can directly monitor the difference inprogress in bytes by doing simply LSN difference calculations, whichshould be monotonic.Note that as the slot is owned by the backend advancing it, then theread of those fields is fine lock-less, while updates need to happenwhile the slot mutex is held, so fix that on the way as well. Otherlocks for in-memory data of replication slots have been already fixedpreviously.Some of those issues have been pointed out by Petr and Simon during thepatch, while I noticed some of them after looking at the code. Thisalso visibly takes of a recently-discovered bug causing assertionfailures which can be triggered by a two-step slot forwarding whichfirst advanced the slot to a WAL page boundary and secondly advanced itto the latest position, say 'FF/FFFFFFF' to make sure that the newestLSN is used as forward point. It would have been nice to drop a testfor that, but the set of operators working on pg_lsn limits it, so thisis left for a future exercise.Author: Michael PaquierReviewed-by: Petr Jelinek, Simon RiggsDiscussion:https://postgr.es/m/CANP8+jLyS=X-CAk59BJnsxKQfjwrmKicHQykyn52Qj-Q=9GLCw@mail.gmail.comDiscussion:https://www.postgresql.org/message-id/2840048a-1184-417a-9da8-3299d207a1d7%40postgrespro.ru1 parent321f648 commitf731cfa
1 file changed
+36
-14
lines changedLines changed: 36 additions & 14 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
318 | 318 |
| |
319 | 319 |
| |
320 | 320 |
| |
| 321 | + | |
| 322 | + | |
| 323 | + | |
321 | 324 |
| |
322 | 325 |
| |
323 |
| - | |
| 326 | + | |
324 | 327 |
| |
325 |
| - | |
| 328 | + | |
| 329 | + | |
326 | 330 |
| |
327 |
| - | |
328 |
| - | |
| 331 | + | |
329 | 332 |
| |
| 333 | + | |
330 | 334 |
| |
| 335 | + | |
331 | 336 |
| |
332 | 337 |
| |
333 |
| - | |
334 | 338 |
| |
335 | 339 |
| |
336 | 340 |
| |
337 | 341 |
| |
338 | 342 |
| |
339 | 343 |
| |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
340 | 350 |
| |
341 | 351 |
| |
342 |
| - | |
| 352 | + | |
343 | 353 |
| |
344 | 354 |
| |
345 | 355 |
| |
346 |
| - | |
| 356 | + | |
| 357 | + | |
347 | 358 |
| |
348 | 359 |
| |
349 | 360 |
| |
| |||
384 | 395 |
| |
385 | 396 |
| |
386 | 397 |
| |
387 |
| - | |
| 398 | + | |
388 | 399 |
| |
389 | 400 |
| |
390 | 401 |
| |
| |||
441 | 452 |
| |
442 | 453 |
| |
443 | 454 |
| |
444 |
| - | |
| 455 | + | |
445 | 456 |
| |
446 | 457 |
| |
447 | 458 |
| |
| |||
472 | 483 |
| |
473 | 484 |
| |
474 | 485 |
| |
475 |
| - | |
476 |
| - | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
477 | 498 |
| |
478 | 499 |
| |
479 | 500 |
| |
480 | 501 |
| |
481 | 502 |
| |
482 | 503 |
| |
483 |
| - | |
| 504 | + | |
484 | 505 |
| |
485 | 506 |
| |
| 507 | + | |
486 | 508 |
| |
487 |
| - | |
| 509 | + | |
488 | 510 |
| |
489 |
| - | |
| 511 | + | |
490 | 512 |
| |
491 | 513 |
| |
492 | 514 |
| |
|
0 commit comments
Comments
(0)