pgsql: Fix more crash-safe visibility map bugs, and improve comments.

Поиск
Список
Период
Сортировка
От Robert Haas
Тема pgsql: Fix more crash-safe visibility map bugs, and improve comments.
Дата
Msg-id E1Scftl-0003CT-Mi@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix more crash-safe visibility map bugs, and improve comments.

In lazy_scan_heap, we could issue bogus warnings about incorrect
information in the visibility map, because we checked the visibility
map bit before locking the heap page, creating a race condition.  Fix
by rechecking the visibility map bit before we complain.  Rejigger
some related logic so that we rely on the possibly-outdated
all_visible_according_to_vm value as little as possible.

In heap_multi_insert, it's not safe to clear the visibility map bit
before beginning the critical section.  The visibility map is not
crash-safe unless we treat clearing the bit as a critical operation.
Specifically, if the transaction were to error out after we set the
bit and before entering the critical section, we could end up writing
the heap page to disk (with the bit cleared) and crashing before the
visibility map page made it to disk.  That would be bad.  heap_insert
has this correct, but somehow the order of operations got rearranged
when heap_multi_insert was added.

Also, add some more comments to visibilitymap_test, lazy_scan_heap,
and IndexOnlyNext, expounding on concurrency issues.

Per extensive code review by Andres Freund, and further review by Tom
Lane, who also made the original report about the bogus warnings.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/b50991eedb458a81d875d049f48fb62ab1685c0d

Modified Files
--------------
src/backend/access/heap/heapam.c         |   18 ++++++++--------
src/backend/access/heap/visibilitymap.c  |   11 ++++++++-
src/backend/commands/vacuumlazy.c        |   34 +++++++++++++++++++++++++----
src/backend/executor/nodeIndexonlyscan.c |   13 +++++++++++
4 files changed, 61 insertions(+), 15 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: fxjr@pgfoundry.org (User Fxjr)
Дата:
Сообщение: npgsql - Npgsql2: [#1011200] Uses API not supported in MonoTouch.
Следующее
От: Simon Riggs
Дата:
Сообщение: pgsql: Wake WALSender to reduce data loss at failover for async commit.