Hi, > For the record, Michael and I had a brief discussion about this > offlist and decided to abandon the idea of adding TAP tests, relying > only on buildfarm. Also I will check if we have a clear error message > in case when a user forgot to run pg_upgrade and running new slru.c > with old filenames. If the user doesn't get such an error message I > will see if it's possible to add it somewhere in slru.c without > introducing much performance overhead. > > Also I'm going to submit precise steps to test this migration manually > for the reviewers convenience.
Here is an updated patch. The steps to test it manually are as follows. Compile and install PostgreSQL from the REL_17_STABLE branch: ``` git checkout REL_17_STABLE git fetch origin git rebase -i origin/REL_17_STABLE git clean -dfx meson setup --buildtype debug -Dcassert=true -Dtap_tests=enabled -Dprefix=/home/eax/pginstall-17 build ninja -C build meson install -C build ~/pginstall-17/bin/initdb --data-checksums -D ~/pginstall-17/data ~/pginstall-17/bin/pg_ctl -D ~/pginstall-17/data -l ~/pginstall-17/data/logfile start ~/pginstall-17/bin/createdb $(whoami) # fill DB (or even better - use a copy of an existing one), e.g: ~/pginstall-17/bin/pgbench -i -s 100 ~/pginstall-17/bin/pgbench -j 16 -c 16 -T 10 -P 5 # should see 4-digit SLRU segment filenames, more files is better ls -la ~/pginstall-17/data/pg_xact/ \ ~/pginstall-17/data/pg_commit_ts/ \ ~/pginstall-17/data/pg_multixact/members/ \ ~/pginstall-17/data/pg_multixact/offsets/ \ ~/pginstall-17/data/pg_subtrans/ \ ~/pginstall-17/data/pg_serial/ ~/pginstall-17/bin/pg_ctl -D ~/pginstall-17/data stop ``` Apply the patch to the `master` branch, recompile PostgreSQL, install to the different location: ``` git checkout slru_pg_upgrade_v2 git clean -dfx meson setup --buildtype debug -Dcassert=true -Dtap_tests=enabled -Dprefix=/home/eax/pginstall-18 build ninja -C build meson install -C build ``` Try to start PostgreSQL without running pg_upgrade: ``` cp -r ~/pginstall-17/data ~/pginstall-18/data ~/pginstall-18/bin/pg_ctl -D ~/pginstall-18/data -l ~/pginstall-18/data/logfile start ``` You should get: ``` waiting for server to start.... stopped waiting pg_ctl: could not start server Examine the log output. $ tail ~/pginstall-18/data/logfile FATAL: database files are incompatible with server DETAIL: The data directory was initialized by PostgreSQL version 17, which is not compatible with this version 18devel ``` Run pg_upgrade: ``` rm -r ~/pginstall-18/data ~/pginstall-18/bin/initdb --data-checksums -D ~/pginstall-18/data ~/pginstall-18/bin/pg_upgrade --old-datadir=/home/eax/pginstall-17/data --new-datadir=/home/eax/pginstall-18/data --old-bindir=/home/eax/pginstall-17/bin --new-bindir=/home/eax/pginstall-18/bin ``` Make sure the output contains: ``` Renaming SLRU segments in pg_xact ok Renaming SLRU segments in pg_commit_ts ok Renaming SLRU segments in pg_multixact/offsets ok Renaming SLRU segments in pg_multixact/members ok Renaming SLRU segments in pg_subtrans ok Renaming SLRU segments in pg_serial ok ``` Make sure PostgreSQL starts after the upgrade: ``` ~/pginstall-18/bin/pg_ctl -D ~/pginstall-18/data -l ~/pginstall-18/data/logfile start ~/pginstall-18/bin/psql -c 'select count(*) from pgbench_accounts' ~/pginstall-18/bin/pg_ctl -D ~/pginstall-18/data stop # should see 15-digit SLRU segment filenames ls -la ~/pginstall-18/data/pg_xact/ \ ~/pginstall-18/data/pg_commit_ts/ \ ~/pginstall-18/data/pg_multixact/members/ \ ~/pginstall-18/data/pg_multixact/offsets/ \ ~/pginstall-18/data/pg_subtrans/ \ ~/pginstall-18/data/pg_serial/ ``` Make sure that the second run of pg_upgrade doesn't produce "Renaming SLRU segments" messages: ``` mv ~/pginstall-18/data ~/pginstall-18/data.bak ~/pginstall-18/bin/initdb --data-checksums -D ~/pginstall-18/data ~/pginstall-18/bin/pg_upgrade --old-datadir=/home/eax/pginstall-18/data.bak --new-datadir=/home/eax/pginstall-18/data --old-bindir=/home/eax/pginstall-18/bin --new-bindir=/home/eax/pginstall-18/bin ``` As always, your feedback and suggestions are most welcomed. -- Best regards, Aleksander Alekseev
v2-0001-Always-use-long-SLRU-segment-file-names.patch
Description: Binary data