Compare commits

...

4 Commits

Author SHA1 Message Date
Amit Kapila f66fcc5cd6 Fix an uninitialized access in hash_xlog_squeeze_page().
Commit 861f86beea changed hash_xlog_squeeze_page() to start reading
the write buffer conditionally but forgot to initialize it leading to an
uninitialized access.

Reported-by: Alexander Lakhin
Author: Hayato Kuroda
Reviewed-by: Alexander Lakhin, Amit Kapila
Discussion: http://postgr.es/m/62ed1a9f-746a-8e86-904b-51b9b806a1d9@gmail.com
2023-12-01 10:22:13 +05:30
Andres Freund aa11a9c149 meson: Stop using deprecated way getting path of files
The just released meson 1.3 strongly deprecated a hack we were using, emitting
a noisy warning (the hack basically depended on an implementation detail to
work). Turns out there has been a better way available for a while, I just
hadn't found it. 1.4 added a more convenient approach, but we can't rely on
that.

Reviewed-by: Tristan Partin <tristan@neon.tech>
Discussion: https://postgr.es/m/20231129185053.s6c7f73eg7b4ztfi@awork3.anarazel.de
Backpatch: 16-, where the meson build was added.
2023-11-30 19:25:40 -08:00
Thomas Munro 3b51265ee3 Adjust obsolete comment explaining set_stack_base().
Commit 7389aad6 removed the notion of backends started from inside a
signal handler.  A stray comment still referred to them, while
explaining the need for a call to set_stack_base().  That leads to the
question of whether we still need the call in !EXEC_BACKEND builds.
There doesn't seem to be much point in suppressing it now, as it doesn't
hurt and probably helps to measure the stack base from the exact same
place in EXEC_BACKEND and !EXEC_BACKEND builds.

Back-patch to 16.

Reported-by: Heikki Linnakangas <hlinnaka@iki.fi>
Reported-by: Tristan Partin <tristan@neon.tech>
Reported-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CA%2BhUKG%2BEJHcevNGNOxVWxTNFbuB%3Dvjf4U68%2B85rAC_Sxvy2zEQ%40mail.gmail.com
2023-12-01 15:18:51 +13:00
Heikki Linnakangas f93133a250 Print lwlock stats also for aux processes, when built with LWLOCK_STATS
InitAuxiliaryProcess() closely resembles InitProcess(), but it didn't
call InitLWLockAccess(). But because InitLWLockAccess() is a no-op
unless compiled with LWLOCK_STATS, and everything works even if it's
not called, the only consequence was that the stats were not printed
for aux processes.

This was an oversight in commit 1c6821be31, in version 9.5, so it is
missing in all supported branches. But since it only affects
developers using LWLOCK_STATS and no one has complained, no
backpatching.

Discussion: https://www.postgresql.org/message-id/20231130202648.7k6agmuizdilufnv@awork3.anarazel.de
2023-12-01 01:00:03 +02:00
6 changed files with 47 additions and 6 deletions

View File

@ -2924,8 +2924,12 @@ potentially_conflicting_files = []
foreach t : potentially_conflicting_files_t
potentially_conflicting_files += t.full_path()
endforeach
foreach t : configure_files
t = '@0@'.format(t)
foreach t1 : configure_files
if meson.version().version_compare('>=0.59')
t = fs.parent(t1) / fs.name(t1)
else
t = '@0@'.format(t1)
endif
potentially_conflicting_files += meson.current_build_dir() / t
endforeach
foreach sub, fnames : generated_sources_ac

View File

@ -632,7 +632,7 @@ hash_xlog_squeeze_page(XLogReaderState *record)
XLogRecPtr lsn = record->EndRecPtr;
xl_hash_squeeze_page *xldata = (xl_hash_squeeze_page *) XLogRecGetData(record);
Buffer bucketbuf = InvalidBuffer;
Buffer writebuf;
Buffer writebuf = InvalidBuffer;
Buffer ovflbuf;
Buffer prevbuf = InvalidBuffer;
Buffer mapbuf;

View File

@ -614,6 +614,13 @@ InitAuxiliaryProcess(void)
* Arrange to clean up at process exit.
*/
on_shmem_exit(AuxiliaryProcKill, Int32GetDatum(proctype));
/*
* Now that we have a PGPROC, we could try to acquire lightweight locks.
* Initialize local state needed for them. (Heavyweight locks cannot be
* acquired in aux processes.)
*/
InitLWLockAccess();
}
/*

View File

@ -107,9 +107,8 @@ InitPostmasterChild(void)
/*
* Set reference point for stack-depth checking. This might seem
* redundant in !EXEC_BACKEND builds; but it's not because the postmaster
* launches its children from signal handlers, so we might be running on
* an alternative stack.
* redundant in !EXEC_BACKEND builds, but it's better to keep the depth
* logic the same with and without that build option.
*/
(void) set_stack_base();

View File

@ -298,6 +298,20 @@ ROLLBACK;
INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 500) as i;
CHECKPOINT;
VACUUM hash_cleanup_heap;
TRUNCATE hash_cleanup_heap;
-- Insert tuples to both the primary bucket page and overflow pages.
INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 500) as i;
-- Fill overflow pages by "dead" tuples.
BEGIN;
INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 1500) as i;
ROLLBACK;
-- And insert some tuples again. During squeeze operation, these will be moved
-- to other overflow pages and also allow overflow pages filled by dead tuples
-- to be freed. Note the main purpose of this test is to test the case where
-- we don't need to move any tuple from the overflow page being freed.
INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 50) as i;
CHECKPOINT;
VACUUM hash_cleanup_heap;
-- Clean up.
DROP TABLE hash_cleanup_heap;
-- Index on temp table.

View File

@ -284,6 +284,23 @@ INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 500) as i;
CHECKPOINT;
VACUUM hash_cleanup_heap;
TRUNCATE hash_cleanup_heap;
-- Insert tuples to both the primary bucket page and overflow pages.
INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 500) as i;
-- Fill overflow pages by "dead" tuples.
BEGIN;
INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 1500) as i;
ROLLBACK;
-- And insert some tuples again. During squeeze operation, these will be moved
-- to other overflow pages and also allow overflow pages filled by dead tuples
-- to be freed. Note the main purpose of this test is to test the case where
-- we don't need to move any tuple from the overflow page being freed.
INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 50) as i;
CHECKPOINT;
VACUUM hash_cleanup_heap;
-- Clean up.
DROP TABLE hash_cleanup_heap;