Re: Inval reliability, especially for inplace updates
Alexander Lakhin <exclusion@gmail.com>
Commits
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Update .abi-compliance-history for PrepareToInvalidateCacheTuple().
- d88f4535d29f 15.16 landed
- a3e7bbd410d4 17.8 landed
- 2e58802f7332 14.21 landed
- 2655d2e47803 16.12 landed
-
Assert lack of hazardous buffer locks before possible catalog read.
- 0dfbd191a939 14.21 landed
- 86091202a8b1 15.16 landed
- 27e4fad9804c 16.12 landed
- bcb784e7d2f9 17.8 landed
- f4ece891fc2f 18.0 landed
-
For inplace update, send nontransactional invalidations.
- 811422471940 14.21 landed
- 1d7b02711f70 16.12 landed
- 05d605b6c69f 15.16 landed
- 0f69beddea11 17.8 landed
- 4cf948cbeedf 12.21 landed
- 0ea9d40a6679 13.17 landed
- e3914bd136e4 14.14 landed
- 4eac5a1fa78e 15.9 landed
- ce8c571d014e 16.5 landed
- 95c5acb3fc26 17.1 landed
- 243e9b40f1b2 18.0 landed
-
Update .abi-compliance-history for CacheInvalidateHeapTupleInplace().
- 06b030e8973f 18.2 landed
-
Revisit cosmetics of "For inplace update, send nontransactional invalidations."
- bae8ca82fd00 18.2 landed
- 64bf53dd61ea 19 (unreleased) landed
-
Correct comments of "Fix data loss at inplace update after heap_update()".
- 0839fbe400d7 19 (unreleased) landed
-
Move I/O before the index_update_stats() buffer lock region.
- d729f1ea5a46 12.21 landed
- 6b01cac0be6d 13.17 landed
- bb3054297661 14.14 landed
- 6d5b4031b927 15.9 landed
- 6c837c237bf8 16.5 landed
- 0bcb9d07940c 17.1 landed
- b412f402d1e0 18.0 landed
-
Revert "For inplace update, send nontransactional invalidations."
- 4b0f7d6c162e 12.21 landed
- fe8091c9e39e 13.17 landed
- 4c7088729503 14.14 landed
- 27642d89081e 15.9 landed
- 6f9dd2282e37 16.5 landed
- c1099dd745b0 17.1 landed
-
Revert "WAL-log inplace update before revealing it to other sessions."
- 5e503e10d13e 12.21 landed
- be74b943c920 13.17 landed
- 9a1c73636d60 14.14 landed
- e50f9de98d63 15.9 landed
- d5be10758b36 16.5 landed
- bc6bad885725 17.1 landed
-
Fix inplace update buffer self-deadlock.
- 0bada39c83a1 18.0 landed
-
Remove duplicate words in comments
- fb7e27abfbd4 18.0 cited
-
At end of recovery, reset all sinval-managed caches.
- da9950456463 12.21 landed
- 67f30c79a1c1 13.17 landed
- dca68242a81b 14.14 landed
- 3baf804b7295 15.9 landed
- d36b4d8ec322 16.5 landed
- a4668c99f0f8 17.1 landed
-
Fix data loss at inplace update after heap_update().
- a07e03fd8fa7 18.0 cited
-
Remove comment about xl_heap_inplace "AT END OF STRUCT".
- c63ceb2f0006 13.16 landed
- 77d0bc8001e6 12.20 landed
- c7f10df36806 14.13 landed
- 2ca8ca4827af 15.8 landed
- e352ba7b7509 16.4 landed
- 4a7f91b3d314 17.0 landed
-
Reduce memory consumption for pending invalidation messages.
- 3aafc030a536 15.0 cited
-
Add support for streaming to built-in logical replication.
- 464824323e57 14.0 cited
-
WAL Log invalidations at command end with wal_level=logical.
- c55040ccd017 14.0 cited
-
Introduce logical decoding.
- b89e151054a0 9.4.0 cited
-
Rename and document some invalidation routines to make it clearer that
- 81d08fcffeed 7.1.1 cited
Attachments
- reproi.sh (application/x-shellscript)
- delay-before-lockbuffer.patch (text/x-patch) patch
- 1143065-bt.txt (text/plain)
Hello Noah,
31.10.2024 04:39, Noah Misch wrote:
> I had pushed this during the indicated week, before your mail. Reverting it
> is an option. Let's see if more opinions arrive.
I've accidentally discovered an incorrect behaviour caused by commit
4eac5a1fa. Running this script:
for ((j=1; j<=100; j++)); do
echo "iteration $j"
cat << 'EOF' | timeout 60 psql >>psql-$SID.log || { res=1; echo "hanged on iteration $j"; break; }
SELECT format('CREATE TABLE t%s (a int, b text);', g) FROM generate_series(1, 50) g
\gexec
SELECT format('DROP TABLE t%s;', g) FROM generate_series(1, 50) g
\gexec
EOF
done
with
autovacuum = on
autovacuum_naptime = 1s
autovacuum_vacuum_threshold = 1
autovacuum_analyze_threshold = 1
in parallel using separate servers (the full script is attached), like:
parallel -j40 --linebuffer --tag .../reproi.sh ::: `seq 40`
I can catch the following:
...
3 hanged on iteration 51
...
19 hanged on iteration 64
...
39 hanged on iteration 99
And after the script run, I see the server processes hanging:
law 1081433 1 0 16:22 ? 00:00:00 .../usr/local/pgsql/bin/postgres
law 1081452 1081433 0 16:22 ? 00:00:00 postgres: checkpointer
law 1081453 1081433 0 16:22 ? 00:00:00 postgres: background writer
law 1081460 1081433 0 16:22 ? 00:00:00 postgres: walwriter
law 1081462 1081433 0 16:22 ? 00:00:00 postgres: autovacuum launcher
law 1081464 1081433 0 16:22 ? 00:00:00 postgres: logical replication launcher
law 1143065 1081433 0 16:32 ? 00:00:00 postgres: postgres postgres [local] CREATE TABLE
law 1143263 1081433 0 16:32 ? 00:00:00 postgres: autovacuum worker postgres
law 1143320 1081433 0 16:32 ? 00:00:00 postgres: autovacuum worker postgres
law 1143403 1081433 0 16:32 ? 00:00:00 postgres: autovacuum worker
Attaching to process 1143065
...
(gdb) bt
#0 __futex_abstimed_wait_common64 (private=<optimized out>, cancel=true, abstime=0x0, op=265, expected=0,
futex_word=0x7fed9a8171b8) at ./nptl/futex-internal.c:57
#1 __futex_abstimed_wait_common (cancel=true, private=<optimized out>, abstime=0x0, clockid=0, expected=0,
futex_word=0x7fed9a8171b8) at ./nptl/futex-internal.c:87
#2 __GI___futex_abstimed_wait_cancelable64 (futex_word=futex_word@entry=0x7fed9a8171b8, expected=expected@entry=0,
clockid=clockid@entry=0, abstime=abstime@entry=0x0, private=<optimized out>) at ./nptl/futex-internal.c:139
#3 0x00007feda4674c5f in do_futex_wait (sem=sem@entry=0x7fed9a8171b8, abstime=0x0, clockid=0) at
./nptl/sem_waitcommon.c:111
#4 0x00007feda4674cf8 in __new_sem_wait_slow64 (sem=0x7fed9a8171b8, abstime=0x0, clockid=0) at ./nptl/sem_waitcommon.c:183
#5 0x0000561dd715f1fe in PGSemaphoreLock (sema=0x7fed9a8171b8) at pg_sema.c:327
#6 0x0000561dd722fe02 in LWLockAcquire (lock=0x7fed9ad9b4e4, mode=LW_SHARED) at lwlock.c:1318
#7 0x0000561dd71f8423 in LockBuffer (buffer=36, mode=1) at bufmgr.c:4182
#8 0x0000561dd6d4f506 in heapam_index_fetch_tuple (scan=0x561dd8cb6588, tid=0x561dd8cb64d0, snapshot=0x561dd8bfee28,
slot=0x561dd8cb75a0, call_again=0x561dd8cb64d6, all_dead=0x7ffdd63842c6) at heapam_handler.c:146
...
(the full backtrace is attached)
All three autovacuum workers (1143263, 1143320, 1143403) are also waiting
for the same buffer lock:
#5 0x0000561dd715f1fe in PGSemaphoreLock (sema=0x7fed9a817338) at pg_sema.c:327
#6 0x0000561dd722fe02 in LWLockAcquire (lock=0x7fed9ad9b4e4, mode=LW_SHARED) at lwlock.c:1318
#7 0x0000561dd71f8423 in LockBuffer (buffer=36, mode=1) at bufmgr.c:4182
Probably, this can be reproduced with VACUUM pg_class/pg_type/..., but I
haven't found out the exact combination needed yet.
Also as a side note, these processes can't be terminated with SIGTERM, I
have to kill them.
Initially I saw this on a slowed down VM, but with the attached patch
applied I could reproduce it on my workstation too.
Best regards,
Alexander