|
386 | 386 | </indexterm>
|
387 | 387 |
|
388 | 388 | <para>
|
389 |
| - <productname>PostgreSQL</productname>'s MVCC transaction semantics |
| 389 | + <productname>PostgreSQL</productname>'s |
| 390 | + <link linkend="mvcc-intro">MVCC</link> transaction semantics |
390 | 391 | depend on being able to compare transaction ID (<acronym>XID</>)
|
391 | 392 | numbers: a row version with an insertion XID greater than the current
|
392 | 393 | transaction's XID is <quote>in the future</> and should not be visible
|
|
404 | 405 | <para>
|
405 | 406 | The reason that periodic vacuuming solves the problem is that
|
406 | 407 | <command>VACUUM</> will mark rows as <emphasis>frozen</>, indicating that
|
407 |
| - they were inserted by a transaction which committed sufficiently far in |
408 |
| - the past that the effects of the inserting transaction is certain to be |
409 |
| - visible, from an MVCC perspective, to all current and future transactions. |
410 |
| - <productname>PostgreSQL</> reserves a special XID, |
411 |
| - <literal>FrozenTransactionId</>, which does not follow the normal XID |
412 |
| - comparison rules and is always considered older |
413 |
| - than every normal XID. Normal XIDs are |
| 408 | + they were inserted by a transaction that committed sufficiently far in |
| 409 | + the past that the effects of the inserting transaction are certain to be |
| 410 | + visible to all current and future transactions. |
| 411 | + Normal XIDs are |
414 | 412 | compared using modulo-2<superscript>32</> arithmetic. This means
|
415 | 413 | that for every normal XID, there are two billion XIDs that are
|
416 | 414 | <quote>older</> and two billion that are <quote>newer</>; another
|
|
420 | 418 | the next two billion transactions, no matter which normal XID we are
|
421 | 419 | talking about. If the row version still exists after more than two billion
|
422 | 420 | transactions, it will suddenly appear to be in the future. To
|
423 |
| - prevent this, frozen row versions are treated as if the inserting XID were |
| 421 | + prevent this, <productname>PostgreSQL</> reserves a special XID, |
| 422 | + <literal>FrozenTransactionId</>, which does not follow the normal XID |
| 423 | + comparison rules and is always considered older |
| 424 | + than every normal XID. |
| 425 | + Frozen row versions are treated as if the inserting XID were |
424 | 426 | <literal>FrozenTransactionId</>, so that they will appear to be
|
425 | 427 | <quote>in the past</> to all normal transactions regardless of wraparound
|
426 | 428 | issues, and so such row versions will be valid until deleted, no matter
|
427 | 429 | how long that is.
|
428 | 430 | </para>
|
429 | 431 |
|
| 432 | + <note> |
| 433 | + <para> |
| 434 | + In <productname>PostgreSQL</> versions before 9.4, freezing was |
| 435 | + implemented by actually replacing a row's insertion XID |
| 436 | + with <literal>FrozenTransactionId</>, which was visible in the |
| 437 | + row's <structname>xmin</> system column. Newer versions just set a flag |
| 438 | + bit, preserving the row's original <structname>xmin</> for possible |
| 439 | + forensic use. However, rows with <structname>xmin</> equal |
| 440 | + to <literal>FrozenTransactionId</> (2) may still be found |
| 441 | + in databases <application>pg_upgrade</>'d from pre-9.4 versions. |
| 442 | + </para> |
| 443 | + <para> |
| 444 | + Also, system catalogs may contain rows with <structname>xmin</> equal |
| 445 | + to <literal>BootstrapTransactionId</> (1), indicating that they were |
| 446 | + inserted during the first phase of <application>initdb</>. |
| 447 | + Like <literal>FrozenTransactionId</>, this special XID is treated as |
| 448 | + older than every normal XID. |
| 449 | + </para> |
| 450 | + </note> |
| 451 | + |
430 | 452 | <para>
|
431 | 453 | <xref linkend="guc-vacuum-freeze-min-age">
|
432 |
| - controls how old an XID value has to be beforeits row version will be |
| 454 | + controls how old an XID value has to be beforerows bearing that XID will be |
433 | 455 | frozen. Increasing this setting may avoid unnecessary work if the
|
434 | 456 | rows that would otherwise be frozen will soon be modified again,
|
435 | 457 | but decreasing this setting increases
|
|