Re: [PoC] Improve dead tuple storage for lazy vacuum

Andres Freund <andres@anarazel.de>

From: Andres Freund <andres@anarazel.de>
To: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: John Naylor <john.naylor@enterprisedb.com>, Nathan Bossart <nathandbossart@gmail.com>, Matthias van de Meent <boekewurm+postgres@gmail.com>, Yura Sokolov <y.sokolov@postgrespro.ru>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2022-11-22T17:10:00Z
Lists: pgsql-hackers
On 2022-11-21 17:06:56 +0900, Masahiko Sawada wrote:
> Sure. I've attached the v10 patches. 0004 is the pure refactoring
> patch and 0005 patch introduces the pointer tagging.

This failed on cfbot, with som many crashes that the VM ran out of disk for
core dumps. During testing with 32bit, so there's probably something broken
around that.

https://cirrus-ci.com/task/4635135954386944

A failure is e.g. at: https://api.cirrus-ci.com/v1/artifact/task/4635135954386944/testrun/build-32/testrun/adminpack/regress/log/initdb.log

performing post-bootstrap initialization ... ../src/backend/lib/radixtree.c:1696:21: runtime error: member access within misaligned address 0x590faf74 for type 'struct radix_tree_control', which requires 8 byte alignment
0x590faf74: note: pointer points here
  90 11 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
              ^
==55813==Using libbacktrace symbolizer.
    #0 0x56dcc274 in rt_create ../src/backend/lib/radixtree.c:1696
    #1 0x56953d1b in tidstore_create ../src/backend/access/common/tidstore.c:57
    #2 0x56a1ca4f in dead_items_alloc ../src/backend/access/heap/vacuumlazy.c:3109
    #3 0x56a2219f in heap_vacuum_rel ../src/backend/access/heap/vacuumlazy.c:539
    #4 0x56cb77ed in table_relation_vacuum ../src/include/access/tableam.h:1681
    #5 0x56cb77ed in vacuum_rel ../src/backend/commands/vacuum.c:2062
    #6 0x56cb9a16 in vacuum ../src/backend/commands/vacuum.c:472
    #7 0x56cba904 in ExecVacuum ../src/backend/commands/vacuum.c:272
    #8 0x5711b6d0 in standard_ProcessUtility ../src/backend/tcop/utility.c:866
    #9 0x5711bdeb in ProcessUtility ../src/backend/tcop/utility.c:530
    #10 0x5711759f in PortalRunUtility ../src/backend/tcop/pquery.c:1158
    #11 0x57117cb8 in PortalRunMulti ../src/backend/tcop/pquery.c:1315
    #12 0x571183d2 in PortalRun ../src/backend/tcop/pquery.c:791
    #13 0x57111049 in exec_simple_query ../src/backend/tcop/postgres.c:1238
    #14 0x57113f9c in PostgresMain ../src/backend/tcop/postgres.c:4551
    #15 0x5711463d in PostgresSingleUserMain ../src/backend/tcop/postgres.c:4028
    #16 0x56df4672 in main ../src/backend/main/main.c:197
    #17 0xf6ad8e45 in __libc_start_main (/lib/i386-linux-gnu/libc.so.6+0x1ae45)
    #18 0x5691d0f0 in _start (/tmp/cirrus-ci-build/build-32/tmp_install/usr/local/pgsql/bin/postgres+0x3040f0)

Aborted (core dumped)
child process exited with exit code 134
initdb: data directory "/tmp/cirrus-ci-build/build-32/testrun/adminpack/regress/tmp_check/data" not removed at user's request



Commits

  1. radixtree: Fix SIGSEGV at update of embeddable value to non-embeddable.

  2. Get rid of anonymous struct

  3. Teach radix tree to embed values at runtime

  4. Teach TID store to skip bitmap for small numbers of offsets

  5. Use bump context for TID bitmaps stored by vacuum

  6. Fix alignment of stack variable

  7. Use TidStore for dead tuple TIDs storage during lazy vacuum.

  8. Rethink create and attach APIs of shared TidStore.

  9. Fix inconsistent function prototypes with function definitions.

  10. Fix a calculation in TidStoreCreate().

  11. Fix potential integer handling issue in radixtree.h.

  12. Add TIDStore, to store sets of TIDs (ItemPointerData) efficiently.

  13. Fix link error for test_radixtree module on Windows

  14. Blind attempt to fix ODR violations

  15. Fix incorrect format specifier for int64

  16. Fix redefinition of typedefs

  17. Add template for adaptive radix tree

  18. Fix signedness error in 9f225e992 for gcc

  19. Introduce helper SIMD functions for small byte arrays

  20. Optimize vacuuming of relations with no indexes.

  21. Add bound check before bsearch() for performance

  22. Allocate consecutive blocks during parallel seqscans