Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warm strategy #270

Open
wants to merge 195 commits into
base: REL_14_STABLE_neon
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
195 commits
Select commit Hold shift + click to select a range
4815e9f
[smgr_api] [community] smgr_api.patch
lubennikovaav May 16, 2021
57e2bba
[contrib/zenith] contrib_zenith.patch
lubennikovaav May 16, 2021
1692904
[walredo] zenith_wal_redo.patch
lubennikovaav May 16, 2021
6afc81e
lastWrittenPageLSN.patch
lubennikovaav May 16, 2021
343a928
Fix GetPage requests right after replaying CREATE DATABASE
hlinnaka May 21, 2021
ffa2d7d
handle_eviction_of_non_wal_logged_pages.patch
lubennikovaav May 16, 2021
eacda29
[walproposer] wal_proposer.patch
lubennikovaav May 16, 2021
250e230
persist_unlogged_tables.patch
lubennikovaav May 16, 2021
521aa5a
fix_pg_table_size.patch
lubennikovaav May 16, 2021
d3b3173
[walredo] fix_gin_redo.patch
lubennikovaav May 16, 2021
c1857b7
[walredo] fix_brin_redo.patch
lubennikovaav May 16, 2021
8ea72ed
speculative_records_workaround.patch
lubennikovaav May 16, 2021
d2a0a67
wallog_t_ctid.patch
lubennikovaav May 16, 2021
0843119
vacuumlazy_debug_stub.patch
lubennikovaav May 16, 2021
da83fc2
[test] zenith_test_evict.patch
lubennikovaav May 16, 2021
16c32da
fix_sequence_wallogging.patch
lubennikovaav May 16, 2021
029fce5
Bring back change that got lost in refactoring. silence ReadBuffer_co…
lubennikovaav May 18, 2021
668bedc
[contrib/zenith] [refer #225] if insert WAL position points at the en…
knizhnik Jun 7, 2021
07a20a8
[walproposer] Create replication slot for walproposer to avoid loose …
knizhnik Jun 8, 2021
e74ef1a
[walproposer] Skip absent WAL segment removed by pg_resetwal
lubennikovaav Aug 17, 2021
e2ce640
[walproposer] Fix breaking out of WalProposerPoll and WaitEventSetWai…
arssher Jun 11, 2021
082ad62
[walproposer] Make it possible to start postgres without reading chec…
knizhnik Jun 17, 2021
996ba4e
[walproposer] Simplify WL_LATCH_SET testing in the walproposer
ololobus Jul 5, 2021
482c9ea
[walredo] Add basic support for Seccomp BPF mode
funbringer Jun 24, 2021
38747b1
[smgr_api] [contrib/zenith] 1. Do not call mdinit from smgrinit() bec…
knizhnik Jul 9, 2021
b499250
[walproposer] [contrib/zenith] support zenith_tenant
LizardWizzard Jul 15, 2021
0b7c0ed
[walproposer] Remove graceful termination of COPY during walproposer …
arssher Aug 4, 2021
6a65961
[walproposer] [contrib/zenith] [refer #395] Do no align sart replicat…
knizhnik Aug 9, 2021
6b9f636
[test] Add contrib/zenith_test_utils with helpers for testing and deb…
lubennikovaav Aug 10, 2021
d7375b2
[walproposer] Change condition for triggering recovery
knizhnik Aug 11, 2021
31a676e
[contrib/zenith] Use authentication token passed as environment varia…
LizardWizzard Aug 4, 2021
cf4690c
[contrib/zenith] Fix race condition while WAL-logging page, leading t…
hlinnaka Aug 13, 2021
4a6f92b
[walproposer] Rework walkeeper protocol to use libpq (#60)
sharnoff Aug 13, 2021
ad780a5
Build zenithdb/compute-node:latest in CI (zenithdb/console#125)
ololobus Aug 16, 2021
7ec534b
zenith_regression_tests.patch
lubennikovaav Aug 23, 2021
f1c99c5
Add test function to flush the shared buffer cache.
hlinnaka Aug 24, 2021
1e8aaed
Basic safekeeper refactoring and bug fixing.
arssher Aug 17, 2021
0928490
Rename VCL to epochStartLsn and restart_lsn to truncate_lsn.
arssher Aug 27, 2021
6950adf
[refer #27] Implement shared relsize cache to improve zenith performa…
knizhnik Aug 3, 2021
9883ca0
Cleanup walproposer changes from #60
sharnoff Aug 31, 2021
51345a5
pass tenant id in connection string to safekeeper
LizardWizzard Aug 31, 2021
67b934c
Ask pageserver only with LSN's aligned on record boundary.
kelvich Aug 31, 2021
b5a4dc1
[refer #506] Correctly initialize all fields of WAL page header for f…
knizhnik Sep 1, 2021
91849df
Add --sync-safekeepers starting standalone walproposer to sync safeke…
knizhnik Aug 19, 2021
7308c90
Update Dockerfile
ololobus Aug 27, 2021
152fd90
Fix compiler warnings in walproposer.c
ololobus Sep 10, 2021
3d0e375
Always advance truncateLsn to commitLsn, keeping it on record boundary.
arssher Sep 9, 2021
ffaea68
Minor logging editing.
arssher Sep 10, 2021
f2afaf8
Fix walproposer starting streaming point.
arssher Sep 10, 2021
7d8a466
Mark all recovery messages as received by the donor.
arssher Sep 14, 2021
106a986
Don't FATAL in walproposer when EOF arrives in SS_IDLE state.
arssher Sep 14, 2021
7906044
Optimize walproposer starting streaming point.
arssher Sep 15, 2021
df143b7
Silence compiler warnings:
hlinnaka Sep 17, 2021
ca53ee4
Remove unused functions for reading non-rel pages.
hlinnaka Sep 17, 2021
7c8b671
Misc cleanup in the code that communicates with the page server.
hlinnaka Sep 17, 2021
9553654
Improve the protocol between Postgres and page server.
hlinnaka Sep 17, 2021
577f16c
Run 'pgindent' on zenith-specific code in contrib/zenith and in walpr…
hlinnaka Sep 17, 2021
59960ed
Fix a badly worded comment
hlinnaka Sep 20, 2021
610336c
Simplify a2e929e by storing starting point in walkeeper itself.
arssher Sep 16, 2021
6b182f6
Catch walkeeper ErrorResponse in PQgetCopyData
sharnoff Sep 22, 2021
fb9dc64
Use buffered I/O for reading commands from stdin.
hlinnaka Sep 24, 2021
41d9f21
Replace fread() with plain read() and a hand-written buffer.
hlinnaka Sep 30, 2021
cb35b6c
Store unlogged tables locally, and replace PD_WAL_LOGGED.
hlinnaka Oct 6, 2021
76f05d3
Fix queue cleanup in proposer (#93)
petuhovskiy Oct 14, 2021
79c418c
Support read-only nodes
hlinnaka Oct 19, 2021
0656694
Remove a drop of syncSafekeepers complexity.
arssher Oct 21, 2021
9c21caf
Fix compiler warning.
arssher Oct 21, 2021
206be72
Implement backpressure for compute node to avoid WAL overflow
knizhnik Sep 18, 2021
3936e4d
Initialize FSM/VM pages through buffer cache
ololobus Oct 19, 2021
d8b905c
Turn off back pressure by default
ololobus Oct 21, 2021
6010993
ShutdownConnection instead of ResetConnection in more places.
arssher Oct 21, 2021
c8d5492
Handle partial writes to stdout in WAL redo process.
hlinnaka Nov 3, 2021
f7a90fc
Handle keepalives while receiving WAL in recovery.
arssher Nov 8, 2021
bafcf0c
Fix truncateLsn update (#101)
petuhovskiy Nov 9, 2021
d10903a
[walproposer] Get rid of SAB_Error after rebase
ololobus Nov 10, 2021
e03bbda
Add term history to safekeepers.
arssher Nov 5, 2021
2903d53
Clarify the meaning of StandbyReply LSNs used for backpressure
lubennikovaav Nov 9, 2021
d98c6a1
Use max_replication_apply_lag instead of max_replication_write_lag.
lubennikovaav Nov 11, 2021
cec97ae
Forward pageserver connection string to safekeeper
LizardWizzard Nov 25, 2021
6c462ed
Move backpressure throttling to ProcessInterrupts()
lubennikovaav Nov 26, 2021
9a59fb5
Stop building docker images in this repo.
kelvich Dec 15, 2021
4d089bb
[walproposer] Async WAL append (#105)
petuhovskiy Dec 21, 2021
d62a176
Fix walsender to work with zenith style standbyReply that sends non-z…
lubennikovaav Dec 22, 2021
a7511e1
Do not copy the obsolete apply_conf binary into Docker image
ololobus Dec 25, 2021
eb638ae
Reorder walproposer code in a more natural order (#112)
petuhovskiy Dec 31, 2021
63f2588
Simplify walproposer code (#114)
petuhovskiy Jan 4, 2022
8b34523
Don't change propTerm after quorum is acquired (#107)
petuhovskiy Jan 4, 2022
0885ab5
walproposer renames (#116)
petuhovskiy Jan 5, 2022
cc70569
Report back-pressure trottling status of backend
knizhnik Dec 29, 2021
6867682
Add max_replication_write_lag
knizhnik Dec 29, 2021
d3a25ad
Do not throttle wal sender
knizhnik Jan 10, 2022
e8658c2
Don't track acks in walproposer (#119)
petuhovskiy Jan 13, 2022
65d5316
Silence excessively noisy logging from walproposer.
hlinnaka Jan 14, 2022
0b222ba
Extend replication protocol with ZenithFeedback message.
lubennikovaav Dec 20, 2021
b730390
Allow to join empty safekeeper to existing cluster (#123)
petuhovskiy Jan 27, 2022
7b0bfc8
Use local relation cache for smgr_exists
knizhnik Dec 29, 2021
dcfcb95
Reduce walproposer logging after ca5e7beaf.
arssher Feb 4, 2022
e7780ea
Implement cluster size quota for zenith compute node.
lubennikovaav Dec 20, 2021
ca4bf36
Revert "Use local relation cache for smgr_exists"
arssher Feb 9, 2022
7140c38
Change the unit of cluster size limit GUC to MB, and other fixes.
hlinnaka Feb 9, 2022
ff279c8
Improve error handling while connecting to page server.
hlinnaka Feb 9, 2022
76847ad
Make getpage requests interruptible.
hlinnaka Feb 9, 2022
a64c4ea
Fix memory leak of messages received from safekeepers.
hlinnaka Feb 10, 2022
785498b
Initialize pgxactoff for walproposer
knizhnik Feb 11, 2022
8e7c5e7
Fix compilation warning after 8524105dc.
arssher Feb 14, 2022
07a0b43
Fix more compiler warnings.
arssher Feb 14, 2022
041dcd4
Remove dead code in handling ZenithFeedback part of an AppendResponse.
hlinnaka Feb 16, 2022
ff03f9d
Expose reading a relation page at a specific LSN (#131)
antons-antons Feb 18, 2022
239c9ea
Add backpressure_lsns() function. Fix zenith feedback processing
lubennikovaav Feb 17, 2022
7a98132
Fix zenith_test_utils linkage on macOS
kelvich Feb 23, 2022
74f4d66
Add warning fr unrecgonized GUCs with zenith prefix
knizhnik Feb 21, 2022
5c033b4
Count WAL flushes in walreceiver (#139)
petuhovskiy Mar 8, 2022
d733e52
Use local relation cache for smgr_exists
knizhnik Dec 29, 2021
b60fbfc
Populate relsize cache when relation is created.
hlinnaka Mar 10, 2022
08cf988
Fix pg_table_size() on a view
hlinnaka Mar 28, 2022
669ca0b
Don't set commitLsn to truncateLsn.
arssher Mar 28, 2022
f62ea8d
Raise fatal error on failed recovery (#147)
petuhovskiy Mar 31, 2022
9cf265d
Enable dumping corrupt WAL segments (#145)
antons-antons Apr 1, 2022
91712dd
Don't hold walproposer WAL in memory (#141)
petuhovskiy Apr 4, 2022
4e18860
Add --sysid parameter to initdb
knizhnik Jan 27, 2022
6b815e1
Give up connection attempt to safekeeper after timeout.
arssher Apr 15, 2022
2dcdc66
Avoid redundand memory allocation and sycnhronization in walredo (#144)
knizhnik Apr 23, 2022
fe66555
Fix missed include for InRecovery (#149)
knizhnik Apr 25, 2022
4232a27
Avoid "bad syscall 39" on assertion failure in WAL redo process.
hlinnaka Apr 26, 2022
43e8389
Add error context, if replaying a WAL record fails in WAL redo process.
hlinnaka Apr 26, 2022
5bfa527
Add WARNING for debugging purposes.
hlinnaka Apr 26, 2022
2b9386c
Turn Assertion into elog(ERROR), to help with debugging.
hlinnaka Apr 26, 2022
4f2dca7
Fix errors in WAL redo about relpersistence mismatch.
hlinnaka Apr 26, 2022
c03b0a1
Don't log 'last written LSN ahead of flushed'.
arssher Apr 26, 2022
34d8436
Perform inmem_smgr cleaup after processing each record (#154)
knizhnik Apr 27, 2022
3c7a2e9
Avoid extending relation in the WAL redo process.
hlinnaka May 3, 2022
c008e21
Send timeline_start_lsn in Elected and receive it in VoteResponse mes…
arssher May 1, 2022
98e72d0
Verify basebackup LSN against consensus LSN in walproposer.
arssher May 2, 2022
31f7244
Implement pg_database_size():
lubennikovaav Jul 23, 2021
586e81d
Shut down instance on basebackup LSN mismatch.
arssher May 6, 2022
f6dddfc
Use compute-tools from the new neondatabase Docker Hub repo
ololobus May 9, 2022
ed24d56
zenith_test_utils extension: add neon_xlogflush()
yeputons May 10, 2022
f5598cb
Reduce noise in the logs from inmem_write()
hlinnaka May 13, 2022
fa5943b
Use compute_ctl instead of zenith_ctl (#162)
ololobus May 18, 2022
8a40962
Improve error messages on seccomp loading errors.
hlinnaka May 24, 2022
a1782cc
Rename contrib/zenith to contrib/neon. Rename custom GUCs:
lubennikovaav May 26, 2022
183816f
Rename 'wal_acceptors' GUC to 'safekeepers'
lubennikovaav Apr 19, 2022
63f278e
Fix basebackup LSN comparison in walproposer.
arssher May 31, 2022
2abcf92
Allow specifiyng the different compute-tools tag (#170)
ololobus May 31, 2022
0a93ced
Do not allocate shared memory for wal_redo process (#165)
knizhnik Jun 6, 2022
146171a
Add check for NULL for malloc in InternalIpcMemoryCreate (#173)
knizhnik Jun 8, 2022
46e506f
Rename ZenithFeedback (#174)
SomeoneToIgnore Jun 10, 2022
60e3d0d
Remove callmemaybe bits from compute (#172)
SomeoneToIgnore Jun 10, 2022
81bbf69
Panic on receiving higher term (#176)
petuhovskiy Jun 22, 2022
47eac27
Misc cleanup in libpagestore.c.
hlinnaka May 16, 2022
353a499
Large last written lsn cache (#177)
knizhnik Jul 9, 2022
03748a1
Add uuid-ossp to the supported extensions (#181)
MMeent Jul 12, 2022
a14ba9e
Update last written LSN for gin/gist index metadata (#182)
knizhnik Jul 19, 2022
8e9de4a
Revert "Update last written LSN for gin/gist index metadata (#182)" (…
knizhnik Jul 26, 2022
e04913a
Fix `uuid-ossp` build
kelvich Aug 1, 2022
e0d6619
Remove redundant const (#189)
bojanserafimov Aug 8, 2022
33da81c
Eliminate UnkonwnXLogRecPtr and always use InvalidXLogRecPtr instead …
knizhnik Aug 12, 2022
478b10b
Init wal redo buffer for fpi (#194)
knizhnik Aug 15, 2022
813a4be
Stamp XLP_FIRST_IS_CONTRECORD only if we start writing with page offset.
arssher Aug 14, 2022
ec8987b
Pull 99% of walproposer code into extension. (#188)
MMeent Aug 18, 2022
f0055ed
Use ECR for image (#195)
zoete Aug 19, 2022
7a8506b
walproposer: do not send pageserver connstring with START_WAL_PUSH (#…
yeputons Aug 25, 2022
5354a96
Remove neon extensions from the vendor repo (#197)
MMeent Aug 25, 2022
6570f1b
Remove Dockerfile, it's now in the neon repo (#199)
ololobus Aug 26, 2022
63020ab
Move backpressure throttling implementation to neon extension (#203)
knizhnik Sep 2, 2022
1b11fb8
Merge last written cache lsn with new main branch (#201)
knizhnik Sep 4, 2022
bf095d3
Local prefetch implementation for Postgres 14
knizhnik Sep 12, 2022
c79a7a6
Disable prefetch by default to make it possible to early merge this P…
knizhnik Sep 12, 2022
2a59925
Disable prefetch by default to make it possible to early merge this P…
knizhnik Sep 12, 2022
f354a65
Update expected output for sysviews test because of changed default v…
knizhnik Sep 12, 2022
40ef430
Set last written page lsn for created relation (#209)
knizhnik Sep 16, 2022
9d9bac2
Undo diasming VM check warning in vacuumlazy.c (#213)
knizhnik Sep 20, 2022
3b03f22
Pin pages with speculative insert tuples to prevent their reconstruct…
knizhnik Oct 20, 2022
d502dcb
Fix shared memory initialization for last written LSN cache (#224)
knizhnik Oct 24, 2022
6686404
Fix upper boundary caculation in the chunks loop in SetLastWrittenLSN…
knizhnik Oct 28, 2022
5294d10
Move walredo process code under pgxn in the main 'neon' repository.
hlinnaka Oct 31, 2022
a43197a
Misc cleanup, mostly to reduce unnecessary differences with upstream.
hlinnaka Oct 31, 2022
076e1b4
Optimize prefetch patterns in both heap seqscan and vacuum scans. (#227)
MMeent Nov 7, 2022
591fcd2
Fix prefetch issues in parallel scans and vacuum's cleanup scan (#234)
MMeent Nov 11, 2022
d95f88a
Use prefetch in pg_prewarm extension (#236)
knizhnik Nov 17, 2022
03fc551
PG14: Prefetch cleanup (#242)
MMeent Nov 23, 2022
7d7a547
Do not produce open file error for unlogged relations (#239)
knizhnik Nov 24, 2022
0d149ea
Maintain last written LSN for each page to enable prefetch on vacuum,…
knizhnik Nov 24, 2022
f890962
Prefetch cleanup: (#247)
MMeent Dec 5, 2022
4159f96
Fix uninitialized variable in spgvacuum.c (#250)
MMeent Dec 7, 2022
e5a660f
Update heap pge LSN in case of VM changes even if wal_redo_hints=off …
knizhnik Dec 8, 2022
5476da2
Show prefetch statistic in EXPLAIN (#248)
knizhnik Jan 12, 2023
1b8c35b
Implement efficient prefetch for parallel bitmap heap scan (#258)
knizhnik Feb 14, 2023
a9f5034
Unlogged index fix v14 (#259)
knizhnik Feb 22, 2023
468d3c0
Fix bitmap scan prefetch (#260)
knizhnik Feb 23, 2023
5fb2e0b
Revert handling of UNLOGGED tables on compute side.
arssher Feb 24, 2023
29fd6af
Allow external main functions to skip config load and make last
kelvich Feb 23, 2023
9fd9794
Remove walredo-related hacks from InternalIpcMemoryCreate()
kelvich Mar 6, 2023
95af329
Do not use ring buffer strategy if there is free space in ring buffer
knizhnik Mar 15, 2023
894e8b0
Update src/backend/storage/buffer/freelist.c
knizhnik Mar 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git
.vscode
.circleci
tmp_install
compute_build
86 changes: 86 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ with_libxml
with_uuid
with_readline
with_systemd
with_libseccomp
with_selinux
with_ldap
with_krb_srvnam
Expand Down Expand Up @@ -858,6 +859,7 @@ with_bsd_auth
with_ldap
with_bonjour
with_selinux
with_libseccomp
with_systemd
with_readline
with_libedit_preferred
Expand Down Expand Up @@ -1564,6 +1566,7 @@ Optional Packages:
--with-ldap build with LDAP support
--with-bonjour build with Bonjour support
--with-selinux build with SELinux support
--with-libseccomp build with libseccomp support
--with-systemd build with systemd support
--without-readline do not use GNU Readline nor BSD Libedit for editing
--with-libedit-preferred
Expand Down Expand Up @@ -8604,6 +8607,39 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_selinux" >&5
$as_echo "$with_selinux" >&6; }

#
# libseccomp
#
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build with libseccomp support" >&5
$as_echo_n "checking whether to build with libseccomp support... " >&6; }



# Check whether --with-libseccomp was given.
if test "${with_libseccomp+set}" = set; then :
withval=$with_libseccomp;
case $withval in
yes)
:
;;
no)
:
;;
*)
as_fn_error $? "no argument expected for --with-libseccomp option" "$LINENO" 5
;;
esac

else
with_libseccomp=no

fi



{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_libseccomp" >&5
$as_echo "$with_libseccomp" >&6; }

#
# Systemd
#
Expand Down Expand Up @@ -14244,6 +14280,56 @@ else
fi


fi

if test "$with_libseccomp" = yes ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for seccomp_init in -lseccomp" >&5
$as_echo_n "checking for seccomp_init in -lseccomp... " >&6; }
if ${ac_cv_lib_seccomp_seccomp_init+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lseccomp $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char seccomp_init ();
int
main ()
{
return seccomp_init ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_seccomp_seccomp_init=yes
else
ac_cv_lib_seccomp_seccomp_init=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_seccomp_seccomp_init" >&5
$as_echo "$ac_cv_lib_seccomp_seccomp_init" >&6; }
if test "x$ac_cv_lib_seccomp_seccomp_init" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBSECCOMP 1
_ACEOF

LIBS="-lseccomp $LIBS"

else
as_fn_error $? "library 'libseccomp' is required for Seccomp BPF support" "$LINENO" 5
fi

fi

# for contrib/uuid-ossp
Expand Down
13 changes: 13 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,14 @@ PGAC_ARG_BOOL(with, selinux, no, [build with SELinux support])
AC_SUBST(with_selinux)
AC_MSG_RESULT([$with_selinux])

#
# libseccomp
#
AC_MSG_CHECKING([whether to build with libseccomp support])
PGAC_ARG_BOOL(with, libseccomp, no, [build with libseccomp support])
AC_SUBST(with_libseccomp)
AC_MSG_RESULT([$with_libseccomp])

#
# Systemd
#
Expand Down Expand Up @@ -1564,6 +1572,11 @@ dnl If you want to use Apple's own Bonjour code on another platform,
dnl just add -ldns_sd to LIBS manually.
fi

if test "$with_libseccomp" = yes ; then
AC_CHECK_LIB(seccomp, seccomp_init, [],
[AC_MSG_ERROR([library 'libseccomp' is required for Seccomp BPF support])])
fi

# for contrib/uuid-ossp
if test "$with_uuid" = bsd ; then
AC_CHECK_HEADERS(uuid.h,
Expand Down
34 changes: 34 additions & 0 deletions contrib/pg_prewarm/autoprewarm.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include "utils/rel.h"
#include "utils/relfilenodemap.h"
#include "utils/resowner.h"
#include "utils/spccache.h"

#define AUTOPREWARM_FILE "autoprewarm.blocks"

Expand Down Expand Up @@ -433,10 +434,12 @@ void
autoprewarm_database_main(Datum main_arg)
{
int pos;
int io_concurrency;
BlockInfoRecord *block_info;
Relation rel = NULL;
BlockNumber nblocks = 0;
BlockInfoRecord *old_blk = NULL;
BlockInfoRecord *prefetch_blk = NULL;
dsm_segment *seg;

/* Establish signal handlers; once that's done, unblock signals. */
Expand Down Expand Up @@ -502,6 +505,8 @@ autoprewarm_database_main(Datum main_arg)

if (!rel)
CommitTransactionCommand();
else
io_concurrency = get_tablespace_maintenance_io_concurrency(rel->rd_rel->reltablespace);
}
if (!rel)
{
Expand Down Expand Up @@ -534,6 +539,35 @@ autoprewarm_database_main(Datum main_arg)
continue;
}

/* if prefetching is enabled for this relation */
if (io_concurrency > 0)
{
/* make prefetch_blk catch up */
if (blk > prefetch_blk)
{
prefetch_blk = blk;
}

/* now, prefetch all following blocks */
while (prefetch_blk <= &block_info[apw_state->prewarm_stop_idx])
{
/* unless they're of a different relfilenode */
if (prefetch_blk->filenode != blk->filenode ||
prefetch_blk->forknum != blk->forknum ||
prefetch_blk->blocknum >= nblocks)
break;

/* or unless they are more than io_concurrency blocks ahead */
if (blk + io_concurrency <= prefetch_blk)
break;

PrefetchBuffer(rel, prefetch_blk->forknum, prefetch_blk->blocknum);

/* continue with the next block */
prefetch_blk++;
}
}

/* Prewarm buffer. */
buf = ReadBufferExtended(rel, blk->forknum, blk->blocknum, RBM_NORMAL,
NULL);
Expand Down
18 changes: 16 additions & 2 deletions contrib/pg_prewarm/pg_prewarm.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
#include "access/relation.h"
#include "fmgr.h"
#include "miscadmin.h"
#include "optimizer/cost.h"
#include "storage/bufmgr.h"
#include "storage/smgr.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
#include "utils/rel.h"
#include "utils/spccache.h"

PG_MODULE_MAGIC;

Expand Down Expand Up @@ -183,14 +185,26 @@ pg_prewarm(PG_FUNCTION_ARGS)
}
else if (ptype == PREWARM_BUFFER)
{
BlockNumber prefetch_block = first_block;
Oid nspOid;
int io_concurrency;

nspOid = rel->rd_rel->reltablespace;
io_concurrency = get_tablespace_maintenance_io_concurrency(nspOid);

/*
* In buffer mode, we actually pull the data into shared_buffers.
*/
for (block = first_block; block <= last_block; ++block)
{
Buffer buf;

Buffer buf;
BlockNumber prefetch_stop = block + Min(last_block - block + 1,
io_concurrency);
CHECK_FOR_INTERRUPTS();
while (prefetch_block < prefetch_stop)
{
PrefetchBuffer(rel, forkNumber, prefetch_block++);
}
buf = ReadBufferExtended(rel, forkNumber, block, RBM_NORMAL, NULL);
ReleaseBuffer(buf);
++blocks_done;
Expand Down
1 change: 1 addition & 0 deletions contrib/pg_prewarm/pg_prewarm.control
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ comment = 'prewarm relation data'
default_version = '1.2'
module_pathname = '$libdir/pg_prewarm'
relocatable = true
trusted = true
1 change: 1 addition & 0 deletions src/Makefile.global.in
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ with_tcl = @with_tcl@
with_ssl = @with_ssl@
with_readline = @with_readline@
with_selinux = @with_selinux@
with_libseccomp = @with_libseccomp@
with_systemd = @with_systemd@
with_gssapi = @with_gssapi@
with_krb_srvnam = @with_krb_srvnam@
Expand Down
3 changes: 2 additions & 1 deletion src/backend/access/brin/brin_xlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ brin_xlog_insert_update(XLogReaderState *record,
}

/* need this page's blkno to store in revmap */
regpgno = BufferGetBlockNumber(buffer);
//ZENITH XXX Don't use BufferGetBlockNumber because wal-redo doesn't pin buffer.
XLogRecGetBlockTag(record, 0, NULL, NULL, &regpgno);

/* insert the index item into the page */
if (action == BLK_NEEDS_REDO)
Expand Down
8 changes: 8 additions & 0 deletions src/backend/access/gin/gininsert.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ ginbuild(Relation heap, Relation index, IndexInfo *indexInfo)
elog(ERROR, "index \"%s\" already contains data",
RelationGetRelationName(index));

smgr_start_unlogged_build(index->rd_smgr);

initGinState(&buildstate.ginstate, index);
buildstate.indtuples = 0;
memset(&buildstate.buildStats, 0, sizeof(GinStatsData));
Expand Down Expand Up @@ -408,6 +410,8 @@ ginbuild(Relation heap, Relation index, IndexInfo *indexInfo)
buildstate.buildStats.nTotalPages = RelationGetNumberOfBlocks(index);
ginUpdateStats(index, &buildstate.buildStats, true);

smgr_finish_unlogged_build_phase_1(index->rd_smgr);

/*
* We didn't write WAL records as we built the index, so if WAL-logging is
* required, write all pages to the WAL now.
Expand All @@ -417,8 +421,12 @@ ginbuild(Relation heap, Relation index, IndexInfo *indexInfo)
log_newpage_range(index, MAIN_FORKNUM,
0, RelationGetNumberOfBlocks(index),
true);
SetLastWrittenLSNForBlockRange(XactLastRecEnd, index->rd_smgr->smgr_rnode.node, MAIN_FORKNUM, 0, RelationGetNumberOfBlocks(index));
SetLastWrittenLSNForRelation(XactLastRecEnd, index->rd_smgr->smgr_rnode.node, MAIN_FORKNUM);
}

smgr_end_unlogged_build(index->rd_smgr);

/*
* Return statistics
*/
Expand Down
19 changes: 13 additions & 6 deletions src/backend/access/gin/ginxlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ ginRedoSplit(XLogReaderState *record)
rootbuf;
bool isLeaf = (data->flags & GIN_INSERT_ISLEAF) != 0;
bool isRoot = (data->flags & GIN_SPLIT_ROOT) != 0;
XLogRedoAction action;

/*
* First clear incomplete-split flag on child page if this finishes a
Expand All @@ -415,21 +416,27 @@ ginRedoSplit(XLogReaderState *record)
if (!isLeaf)
ginRedoClearIncompleteSplit(record, 3);

if (XLogReadBufferForRedo(record, 0, &lbuffer) != BLK_RESTORED)
action = XLogReadBufferForRedo(record, 0, &lbuffer);
if (action != BLK_RESTORED && action != BLK_DONE)
elog(ERROR, "GIN split record did not contain a full-page image of left page");

if (XLogReadBufferForRedo(record, 1, &rbuffer) != BLK_RESTORED)
action = XLogReadBufferForRedo(record, 1, &rbuffer);
if (action != BLK_RESTORED && action != BLK_DONE)
elog(ERROR, "GIN split record did not contain a full-page image of right page");

if (isRoot)
{
if (XLogReadBufferForRedo(record, 2, &rootbuf) != BLK_RESTORED)
action = XLogReadBufferForRedo(record, 2, &rootbuf);
if (action != BLK_RESTORED && action != BLK_DONE)
elog(ERROR, "GIN split record did not contain a full-page image of root page");
UnlockReleaseBuffer(rootbuf);
if (rootbuf != InvalidBuffer)
UnlockReleaseBuffer(rootbuf);
}

UnlockReleaseBuffer(rbuffer);
UnlockReleaseBuffer(lbuffer);
if (rbuffer != InvalidBuffer)
UnlockReleaseBuffer(rbuffer);
if (lbuffer != InvalidBuffer)
UnlockReleaseBuffer(lbuffer);
}

/*
Expand Down
Loading