Skip to content

Commit 9cfe018

Browse files
committed
fix: address review comments and fix tests
1 parent 6483db8 commit 9cfe018

7 files changed

Lines changed: 355 additions & 53 deletions

File tree

Dockerfile-multigres

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,13 @@ RUN for f in /nix/var/nix/profiles/default/bin/*; do \
189189
RUN chown -R postgres:postgres /usr/lib/postgresql && \
190190
chown -R postgres:postgres /usr/share/postgresql
191191

192-
RUN ln -sf /nix/var/nix/profiles/default/bin/pgctld /usr/local/bin/pgctld
192+
COPY docker/pgctld/postgresql.conf.tmpl /etc/pgctld/postgresql.conf.tmpl
193+
194+
# Wrapper: injects --postgres-config-template on every pgctld call so the team's
195+
# unmodified k8s manifests and local provisioner commands work without extra flags.
196+
RUN printf '#!/bin/sh\nexec /nix/var/nix/profiles/default/bin/pgctld --postgres-config-template /etc/pgctld/postgresql.conf.tmpl "$@"\n' \
197+
> /usr/local/bin/pgctld && \
198+
chmod +x /usr/local/bin/pgctld
193199

194200
# Strip extensions absent from pg17 vanilla build
195201
RUN sed -i 's/ timescaledb,//g; s/ plv8,//g' /etc/postgresql-custom/supautils.conf

docker/pgctld/orioledb-postgresql.conf.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ restart_after_crash = off # reinitialize after backend crash?
281281
# Add settings for extensions here
282282
auto_explain.log_min_duration = 10s
283283
cron.database_name = 'postgres'
284+
pgsodium.getkey_script = '/usr/lib/postgresql/bin/pgsodium_getkey.sh'
285+
vault.getkey_script = '/usr/lib/postgresql/bin/pgsodium_getkey.sh'
284286
wal_log_hints = 'on'
285287

286288
#------------------------------------------------------------------------------

docker/pgctld/postgresql.conf.tmpl

Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
# ╔══════════════════════════════════════════════════════════════════════════════╗
2+
# ║ ║
3+
# ║ PostgreSQL Configuration ║
4+
# ║ ║
5+
# ║ Generated by Multigres - Helping you Scale PostgreSQL ║
6+
# ║ ║
7+
# ║ This configuration contains optimized settings for PostgreSQL ║
8+
# ║ instances managed by Multigres.
9+
# ║ will be replaced with actual values during deployment.
10+
# ║ ║
11+
# ║ ║
12+
# ╚══════════════════════════════════════════════════════════════════════════════╝
13+
14+
15+
#------------------------------------------------------------------------------
16+
# CONNECTIONS AND AUTHENTICATION
17+
#------------------------------------------------------------------------------
18+
19+
# - Connection Settings -
20+
# Port, listen_addresses, and unix_socket_directories are passed as command-line parameters
21+
# This ensures backups remain portable across different environments
22+
max_connections = {{.MaxConnections}}
23+
24+
# - Authentication -
25+
26+
authentication_timeout = 1min # 1s-600s
27+
password_encryption = scram-sha-256 # scram-sha-256 or md5
28+
29+
# GSSAPI using Kerberos
30+
31+
# - SSL -
32+
33+
ssl = off
34+
ssl_ca_file = ''
35+
ssl_cert_file = ''
36+
ssl_crl_file = ''
37+
ssl_crl_dir = ''
38+
ssl_key_file = ''
39+
ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers
40+
ssl_prefer_server_ciphers = on
41+
ssl_ecdh_curve = 'prime256v1'
42+
ssl_min_protocol_version = 'TLSv1.2'
43+
ssl_max_protocol_version = ''
44+
ssl_dh_params_file = ''
45+
ssl_passphrase_command = ''
46+
ssl_passphrase_command_supports_reload = off
47+
48+
49+
#------------------------------------------------------------------------------
50+
# RESOURCE USAGE (except WAL)
51+
#------------------------------------------------------------------------------
52+
53+
# - Memory -
54+
55+
shared_buffers = {{.SharedBuffers}} # min 128kB
56+
# (change requires restart)
57+
maintenance_work_mem = {{.MaintenanceWorkMem}} # min 1MB
58+
work_mem = {{.WorkMem}} # min 64kB
59+
60+
# - Disk -
61+
62+
# - Kernel Resources -
63+
64+
max_worker_processes = {{.MaxWorkerProcesses}} # (change requires restart)
65+
66+
# - Cost-Based Vacuum Delay -
67+
68+
# - Background Writer -
69+
70+
# - Asynchronous Behavior -
71+
72+
effective_io_concurrency = {{.EffectiveIoConcurrency}} # 1-1000; 0 disables prefetching
73+
max_parallel_workers = {{.MaxParallelWorkers}} # max number of parallel workers
74+
max_parallel_workers_per_gather = {{.MaxParallelWorkersPerGather}} # taken from max_parallel_workers
75+
max_parallel_maintenance_workers = {{.MaxParallelMaintenanceWorkers}} # taken from max_parallel_workers
76+
77+
78+
#------------------------------------------------------------------------------
79+
# WRITE-AHEAD LOG
80+
#------------------------------------------------------------------------------
81+
82+
# - Settings -
83+
84+
wal_level = logical # minimal, replica, or logical
85+
# (change requires restart)
86+
wal_buffers = {{.WalBuffers}} # min 32kB, -1 sets based on shared_buffers
87+
# (change requires restart)
88+
min_wal_size = {{.MinWalSize}}
89+
max_wal_size = {{.MaxWalSize}}
90+
wal_keep_size = 1000
91+
92+
# - Checkpoints -
93+
94+
checkpoint_completion_target = {{.CheckpointCompletionTarget}} # checkpoint target duration, 0.0 - 1.0
95+
checkpoint_flush_after = 256kB # measured in pages, 0 disables
96+
97+
# - Archiving -
98+
99+
# - Archive Recovery -
100+
101+
# These are only used in recovery mode.
102+
103+
# - Recovery Target -
104+
105+
# Set these only when performing a targeted recovery.
106+
107+
108+
#------------------------------------------------------------------------------
109+
# REPLICATION
110+
#------------------------------------------------------------------------------
111+
112+
# - Sending Servers -
113+
114+
max_wal_senders = {{.MaxWalSenders}} # max number of walsender processes
115+
# (change requires restart)
116+
max_replication_slots = {{.MaxReplicationSlots}} # max number of replication slots
117+
# (change requires restart)
118+
max_slot_wal_keep_size = 4096 # in megabytes; -1 disables
119+
120+
# - Primary Server -
121+
122+
# These settings are ignored on a standby server.
123+
124+
# - Standby Servers -
125+
126+
# These settings are ignored on a primary server.
127+
128+
# - Subscribers -
129+
130+
# These settings are ignored on a publisher.
131+
132+
133+
#------------------------------------------------------------------------------
134+
# QUERY TUNING
135+
#------------------------------------------------------------------------------
136+
137+
# - Planner Method Configuration -
138+
139+
# - Planner Cost Constants -
140+
141+
effective_cache_size = {{.EffectiveCacheSize}}
142+
random_page_cost = {{.RandomPageCost}} # same scale as above
143+
144+
# - Genetic Query Optimizer -
145+
146+
# - Other Planner Options -
147+
148+
default_statistics_target = {{.DefaultStatisticsTarget}} # range 1-10000
149+
150+
151+
#------------------------------------------------------------------------------
152+
# REPORTING AND LOGGING
153+
#------------------------------------------------------------------------------
154+
155+
# These are relevant when logging to syslog:
156+
157+
# This is only relevant when logging to eventlog (Windows):
158+
# (change requires restart)
159+
160+
# - When to Log -
161+
162+
# - What to Log -
163+
164+
log_line_prefix = '%h %m [%p] %q%u@%d ' # special values:
165+
# %a = application name
166+
# %u = user name
167+
# %d = database name
168+
# %r = remote host and port
169+
# %h = remote host
170+
# %b = backend type
171+
# %p = process ID
172+
# %P = process ID of parallel group leader
173+
# %t = timestamp without milliseconds
174+
# %m = timestamp with milliseconds
175+
# %n = timestamp with milliseconds (as a Unix epoch)
176+
# %Q = query ID (0 if none or not computed)
177+
# %i = command tag
178+
# %e = SQL state
179+
# %c = session ID
180+
# %l = session line number
181+
# %s = session start timestamp
182+
# %v = virtual transaction ID
183+
# %x = transaction ID (0 if none)
184+
# %q = stop here in non-session
185+
# processes
186+
# %% = '%'
187+
# e.g. '<%u%%%d> '
188+
log_statement = 'ddl' # none, ddl, mod, all
189+
log_timezone = 'UTC'
190+
191+
#------------------------------------------------------------------------------
192+
# PROCESS TITLE
193+
#------------------------------------------------------------------------------
194+
195+
cluster_name = 'main' # added to process titles if nonempty
196+
# (change requires restart)
197+
198+
199+
#------------------------------------------------------------------------------
200+
# STATISTICS
201+
#------------------------------------------------------------------------------
202+
203+
# - Query and Index Statistics Collector -
204+
205+
206+
# - Monitoring -
207+
208+
209+
#------------------------------------------------------------------------------
210+
# AUTOVACUUM
211+
#------------------------------------------------------------------------------
212+
213+
214+
#------------------------------------------------------------------------------
215+
# CLIENT CONNECTION DEFAULTS
216+
#------------------------------------------------------------------------------
217+
218+
# - Statement Behavior -
219+
220+
row_security = on
221+
222+
timezone = 'UTC'
223+
224+
# Locale settings (lc_messages, lc_monetary, lc_numeric, lc_time) are
225+
# inherited from the container environment (LANG, LC_ALL).
226+
227+
# default configuration for text search
228+
default_text_search_config = 'pg_catalog.english'
229+
230+
# - Shared Library Preloading -
231+
232+
shared_preload_libraries = 'pg_stat_statements, pgaudit, plpgsql, plpgsql_check, pg_cron, pg_net, auto_explain, pg_tle, plan_filter, supabase_vault'
233+
234+
jit_provider = 'llvmjit' # JIT library to use
235+
236+
# - Other Defaults -
237+
238+
#------------------------------------------------------------------------------
239+
# LOCK MANAGEMENT
240+
#------------------------------------------------------------------------------
241+
242+
#deadlock_timeout = 1s
243+
244+
245+
#------------------------------------------------------------------------------
246+
# VERSION AND PLATFORM COMPATIBILITY
247+
#------------------------------------------------------------------------------
248+
249+
# - Previous PostgreSQL Versions -
250+
251+
# - Other Platforms and Clients -
252+
253+
254+
#------------------------------------------------------------------------------
255+
# ERROR HANDLING
256+
#------------------------------------------------------------------------------
257+
258+
#exit_on_error = off # terminate session on any error?
259+
restart_after_crash = off # reinitialize after backend crash?
260+
#data_sync_retry = off # retry or panic on failure to fsync
261+
# data?
262+
# (change requires restart)
263+
#recovery_init_sync_method = fsync # fsync, syncfs (Linux 5.8+)
264+
265+
266+
#------------------------------------------------------------------------------
267+
# CONFIG FILE INCLUDES
268+
#------------------------------------------------------------------------------
269+
270+
# These options allow settings to be loaded from files other than the
271+
# default postgresql.conf. Note that these are directives, not variable
272+
# assignments, so they can usefully be given more than once.
273+
274+
# Automatically generated optimizations
275+
# User-supplied custom parameters, override any automatically generated ones
276+
277+
# WAL-G specific configurations
278+
279+
#------------------------------------------------------------------------------
280+
# CUSTOMIZED OPTIONS
281+
#------------------------------------------------------------------------------
282+
283+
# Add settings for extensions here
284+
auto_explain.log_min_duration = 10s
285+
cron.database_name = 'postgres'
286+
pgsodium.getkey_script = '/usr/lib/postgresql/bin/pgsodium_getkey.sh'
287+
vault.getkey_script = '/usr/lib/postgresql/bin/pgsodium_getkey.sh'
288+
wal_log_hints = 'on'

nix/packages/docker-image-test.nix

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,8 @@ writeShellApplication {
350350
# 6. shared_preload_libraries must include orioledb — injected by wrapper, no flags needed
351351
local spl
352352
spl=$(docker exec "$container" sh -c "
353-
psql -U postgres -h $pooler_dir/pg_sockets \
354-
-tAc \"SHOW shared_preload_libraries;\" 2>&1")
353+
psql -U $POSTGRES_USER -d postgres -h $pooler_dir/pg_sockets \
354+
-tAc \"SHOW shared_preload_libraries;\" 2>&1") || true
355355
if ! echo "$spl" | grep -q "orioledb"; then
356356
log_error " orioledb not in shared_preload_libraries (got: $spl)"
357357
log_error " Check that wrapper script injects --postgres-config-template"
@@ -362,8 +362,8 @@ writeShellApplication {
362362
# 7. default_table_access_method must be orioledb
363363
local tam
364364
tam=$(docker exec "$container" sh -c "
365-
psql -U postgres -h $pooler_dir/pg_sockets \
366-
-tAc \"SHOW default_table_access_method;\" 2>&1")
365+
psql -U $POSTGRES_USER -d postgres -h $pooler_dir/pg_sockets \
366+
-tAc \"SHOW default_table_access_method;\" 2>&1") || true
367367
if ! echo "$tam" | grep -q "orioledb"; then
368368
log_error " default_table_access_method is not orioledb (got: $tam)"
369369
exit 1

nix/packages/pgctld.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ buildGoModule {
1717
'';
1818
# Tests require a running PostgreSQL instance (integration tests); skip in sandbox.
1919
doCheck = false;
20-
vendorHash = "sha256-0G/l5MlEnyXSoElPbRkn1MaQNCtil3rE/tPZILbhKaA=";
20+
vendorHash = "sha256-HesmA96WVxnBvspLc9FZ5M4m5J/T5r6ymaui8g58yMM=";
2121

2222
meta = {
2323
description = "PostgreSQL control daemon for Multigres cluster lifecycle management";

0 commit comments

Comments
 (0)