Skip to main content

Configuration

pg-kinetic accepts configuration from defaults, a TOML file, environment variables, and CLI flags.

Precedence

  1. Built-in defaults are created first.
  2. When --config-file or PG_KINETIC_CONFIG_FILE is set, pg-kinetic parses that TOML file at startup.
  3. Non-default CLI flags and non-default environment values override the TOML file.

The merge code compares the base CLI/env config against Config::default(). A value equal to the built-in default is not treated as an override.

Unknown TOML fields are not a safe validation mechanism. Use pg-kinetic preflight --config <path> and a real startup check before rollout.

Minimal Runtime Config

[connection]
listen_addr = "0.0.0.0:6432"
backend_addr = "127.0.0.1:5432"

[health]
health_addr = "0.0.0.0:9091"
readiness_backend_check_interval_ms = 1000
readiness_timeout_ms = 5000

Route Config

routes is parsed from TOML, but the current proxy runtime uses only the first effective route:

[[routes]]
[routes.primary]
address = "127.0.0.1:5432"
connect_timeout_ms = 1000
tls_mode = "disable"

[[routes.replicas]]
address = "127.0.0.1:5433"
connect_timeout_ms = 1000
tls_mode = "disable"
weight = 1

[routes.read_routing]
read_routing_mode = "prefer_replica"
fallback_policy = "primary"

[routes.freshness]
freshness_policy = "session_write_lsn"
max_replica_lag_ms = 1000
read_after_write_timeout_ms = 500

[routes.ha]
replica_health_interval_ms = 1000
replica_health_timeout_ms = 500

If routes is empty, the proxy builds one route from connection.backend_addr.

Database/User Pools

[[pools]] maps a startup database and user pair to a backend service address.

[[pools]]
database = "app_a"
user = "app_a"
backend_addr = "127.0.0.1:5432"
max_backends = 20

[[pools]]
database = "app_b"
user = "app_b"
backend_addr = "127.0.0.1:5432"

If [[pools]] is empty, pg-kinetic keeps the existing single default route from connection.backend_addr.

When [[pools]] is non-empty, the startup database and user must match one configured pool before backend checkout. Application name is intentionally ignored for selection. Unmatched clients are rejected with SQLSTATE 3D000, and duplicate (database,user) entries are rejected during configuration parsing.

Each pool is bounded by the lower of the global capacity.max_backends and its optional max_backends. The global capacity.max_backends semaphore remains the aggregate cap across all configured pools; it is not multiplied by the number of [[pools]] entries.

v1 uses a single shared backend service identity: pg-kinetic does not infer per-pool credentials. In pass-through authentication, client credentials continue to be forwarded according to the existing auth configuration; pool entries only select the configured backend_addr.

Query Guardrails

Guardrails run after the existing SQL analysis and fingerprinting step and before backend checkout. Defaults keep them disabled.

[guardrails]
mode = "observe"
block_unqualified_dml = true
block_ddl = true
allowlist_file = "/etc/pg-kinetic/query-fingerprints.txt"

Use the rollout sequence Observe -> review -> Enforce: first collect bounded fingerprint observations, review the resulting fingerprint shapes without exposing query literals, then populate the bounded allowlist and switch to enforce. Observe mode allows traffic. Enforce mode allows only allowlisted fingerprints; hard rules remain denials in enforce mode. Invalid allowlist reloads keep the last valid atomic snapshot.

SHOW GUARDRAILS reports only mode, hard-rule switches, and bounded counts. Denials use SQLSTATE 42501 and a generic message. pg_kinetic_guardrail_denials_total uses only the fixed rule labels unqualified_dml, ddl, and unknown_fingerprint.

Runtime Field Reference

FieldTypeDefaultCLIEnvironmentReloadFailure mode
connection.listen_addrsocket address127.0.0.1:6543--listen-addrPG_KINETIC_LISTEN_ADDRrestartStartup fails if bind fails or value cannot parse.
connection.backend_addrsocket address127.0.0.1:5432--backend-addrPG_KINETIC_BACKEND_ADDRrestartStartup/preflight fails if value cannot parse; readiness fails when backend cannot connect.
capacity.max_clientsinteger10000--max-clientsPG_KINETIC_MAX_CLIENTSrestartClient admission is capped at this value.
capacity.max_backendsinteger100--max-backendsPG_KINETIC_MAX_BACKENDSrestartGlobal backend connection cap; each pool is capped by the lower of this value and pool_max_size.
capacity.max_checkout_waitersinteger1000--max-checkout-waitersPG_KINETIC_MAX_CHECKOUT_WAITERSrestartExcess backend checkout waiters are rejected.
pool_max_sizeinteger100--pool-max-sizePG_KINETIC_POOL_MAX_SIZErestartLifecycle-aware per-pool cap; each pool is capped by the lower of this value and capacity.max_backends.
pool_min_idleinteger0--pool-min-idlePG_KINETIC_POOL_MIN_IDLErestartIdle reaping never removes connections below this floor.
pool_idle_timeout_msmilliseconds1800000--pool-idle-timeout-msPG_KINETIC_POOL_IDLE_TIMEOUT_MSrestartIdle backends older than this bound are eligible for reaping. 0 disables the bound.
pool_max_lifetime_msmilliseconds0--pool-max-lifetime-msPG_KINETIC_POOL_MAX_LIFETIME_MSrestartIdle backends older than this lifetime are eligible for reaping. 0 disables the bound.
performance.checkout_timeout_msmilliseconds1000--checkout-timeout-msPG_KINETIC_CHECKOUT_TIMEOUT_MSrestartBackend checkout times out after this duration.
performance.pool_modeenumtransaction--pool-modePG_KINETIC_POOL_MODErestartValues are transaction and session. Session mode dedicates a checked-out backend to a client until disconnect.
performance.recovery_modeenumrecover--recovery-modePG_KINETIC_RECOVERY_MODErestartInvalid enum fails parse. Values: recover, rollback_only, drop.
performance.recovery_timeout_msmilliseconds5000--recovery-timeout-msPG_KINETIC_RECOVERY_TIMEOUT_MSrestartRecovery exceeding this duration discards the backend.
performance.backend_reset_querystringDISCARD ALL--backend-reset-queryPG_KINETIC_BACKEND_RESET_QUERYrestartInvalid SQL fails at backend execution time.
guardrails.modeenumoff--guardrails-modePG_KINETIC_GUARDRAILS_MODErestartValues are off, observe, and enforce.
guardrails.block_unqualified_dmlboolfalse--guardrails-block-unqualified-dmlPG_KINETIC_GUARDRAILS_BLOCK_UNQUALIFIED_DMLrestartIn enforce mode, conservatively blocks unqualified DELETE and UPDATE statements.
guardrails.block_ddlboolfalse--guardrails-block-ddlPG_KINETIC_GUARDRAILS_BLOCK_DDLrestartIn enforce mode, blocks classified DDL statements before backend checkout.
guardrails.allowlist_fileoptional pathunset--guardrails-allowlist-filePG_KINETIC_GUARDRAILS_ALLOWLIST_FILEreloadNew files replace the bounded allowlist atomically; invalid files leave the previous snapshot active.
qos.max_route_in_flightinteger100--max-route-in-flightPG_KINETIC_MAX_ROUTE_IN_FLIGHTrestartRoute concurrency above the cap queues or rejects.
qos.max_route_waitersinteger1000--max-route-waitersPG_KINETIC_MAX_ROUTE_WAITERSrestartExcess route waiters are rejected.
qos.query_timeout_msmilliseconds30000--query-timeout-msPG_KINETIC_QUERY_TIMEOUT_MSrestartQuery cycle times out after this duration.
qos.idle_client_timeout_msmilliseconds300000--idle-client-timeout-msPG_KINETIC_IDLE_CLIENT_TIMEOUT_MSrestartIdle client sessions are closed.
qos.idle_transaction_timeout_msmilliseconds60000--idle-transaction-timeout-msPG_KINETIC_IDLE_TRANSACTION_TIMEOUT_MSrestartIdle pinned transactions are closed or recovered.
qos.max_client_buffer_bytesbytes1048576--max-client-buffer-bytesPG_KINETIC_MAX_CLIENT_BUFFER_BYTESrestartClient buffering above the cap fails the session.
qos.max_backend_buffer_bytesbytes4194304--max-backend-buffer-bytesPG_KINETIC_MAX_BACKEND_BUFFER_BYTESrestartBackend buffering above the cap fails or discards the backend.
qos.overload_error_codeSQLSTATE string53300--overload-error-codePG_KINETIC_OVERLOAD_ERROR_CODErestartInvalid SQLSTATE shape can produce invalid client-facing errors.
admin.admin_addroptional socket addressunset--admin-addrPG_KINETIC_ADMIN_ADDRrestartStartup fails if bind fails.
admin.admin_require_tlsboolfalse--admin-require-tlsPG_KINETIC_ADMIN_REQUIRE_TLSrestartStartup fails when TLS is required but server TLS config cannot load.
admin.admin_allowed_useroptional stringunset--admin-allowed-userPG_KINETIC_ADMIN_ALLOWED_USERrestartNon-matching admin startup user is rejected.
admin.admin_query_timeout_msmilliseconds1000--admin-query-timeout-msPG_KINETIC_ADMIN_QUERY_TIMEOUT_MSrestartAdmin query handling times out.
admin.admin_max_clientsinteger8--admin-max-clientsPG_KINETIC_ADMIN_MAX_CLIENTSrestartExcess admin clients wait or are rejected.
observability.metrics_addroptional socket addressunset--metrics-addrPG_KINETIC_METRICS_ADDRrestartStartup fails if metrics bind fails.
observability.log_levelstringinfo--log-levelPG_KINETIC_LOG_LEVELrestartA level (trace, debug, info, warn, error, off) or a filter directive such as pg_kinetic=debug,warn. RUST_LOG takes precedence when set. Startup fails on an unknown level or a malformed directive rather than falling back silently.
observability.log_formatenumtext--log-formatPG_KINETIC_LOG_FORMATrestartValues: text, json. Use json for structured log collection.
observability.debug_trace_sampling_ratefloat0.0--debug-trace-sampling-ratePG_KINETIC_DEBUG_TRACE_SAMPLING_RATErestartNon-finite values are clamped to 0.0 at use.
observability.phase_timing_sample_ratefloat1.0--phase-timing-sample-ratePG_KINETIC_PHASE_TIMING_SAMPLE_RATErestartDetailed protocol phase histograms are sampled per session; values are clamped to 0.0..=1.0, and core health, pool, error, and backpressure metrics remain unsampled.
observability.otel_enabledboolfalse--otel-enabledPG_KINETIC_OTEL_ENABLEDrestartExport is disabled when false.
observability.otel_endpointoptional stringunset--otel-endpointPG_KINETIC_OTEL_ENDPOINTrestartInvalid endpoint fails at exporter setup/use.
observability.otel_service_namestringpg-kinetic--otel-service-namePG_KINETIC_OTEL_SERVICE_NAMErestartEmpty or misleading names affect telemetry identity.
audit.enabledboolfalse--audit-enabledPG_KINETIC_AUDIT_ENABLEDrestartEnables bounded asynchronous statement audit records.
audit.sinkoptional pathunset--audit-sinkPG_KINETIC_AUDIT_SINKrestartJSON-lines destination; unset writes to stderr. Sink errors do not stop the proxy.
audit.sample_ratefloat1.0--audit-sample-ratePG_KINETIC_AUDIT_SAMPLE_RATErestartDeterministic fingerprint-based sampling, clamped to 0.0..=1.0.
audit.include_readsboolfalse--audit-include-readsPG_KINETIC_AUDIT_INCLUDE_READSrestartIncludes read-class statements; writes and non-read classes remain eligible by default.
tls.client_tls_modeenumdisable--client-tls-modePG_KINETIC_CLIENT_TLS_MODErestartInvalid enum fails parse. Values: disable, allow, require, verify_client.
tls.client_cert_pathoptional pathunset--client-cert-pathPG_KINETIC_CLIENT_TLS_CERT_PATHrestartTLS startup fails if required file cannot load.
tls.client_key_pathoptional pathunset--client-key-pathPG_KINETIC_CLIENT_TLS_KEY_PATHrestartTLS startup fails if required key cannot load.
tls.client_ca_pathoptional pathunset--client-ca-pathPG_KINETIC_CLIENT_TLS_CA_PATHrestartClient verification fails if CA cannot load.
tls.backend_tls_modeenumdisable--backend-tls-modePG_KINETIC_BACKEND_TLS_MODErestartInvalid enum fails parse. Values: disable, prefer, require, verify_ca, verify_full.
tls.backend_ca_pathoptional pathunset--backend-ca-pathPG_KINETIC_BACKEND_TLS_CA_PATHrestartBackend verification fails if CA cannot load.
tls.backend_server_nameoptional stringunset--backend-server-namePG_KINETIC_BACKEND_TLS_SERVER_NAMErestartverify_full fails when name does not match backend cert.
auth.auth_modeenumpass_through--auth-modePG_KINETIC_AUTH_MODErestartInvalid enum fails parse. Values: pass_through, trust, scram_sha_256, md5.
auth.auth_users_fileoptional pathunset--auth-users-filePG_KINETIC_AUTH_USERS_FILEreload assetStartup/reload fails if the file cannot load.
auth.backend_useroptional stringunset--backend-userPG_KINETIC_BACKEND_USERreloadMust be paired with auth.backend_password_env_var_name; selects the dedicated upstream service role after local client authentication. Successful reloads retire idle pooled backends.
auth.backend_password_env_var_nameoptional stringunset--backend-password-env-var-namePG_KINETIC_BACKEND_PASSWORD_ENV_VAR_NAMEreloadMust be paired with auth.backend_user; names the injected service password read by EnvironmentCredentialProvider. Service credentials are invalid with pass_through; successful reloads retire idle pooled backends.
auth.auth_query_enabledboolfalse--auth-query-enabledPG_KINETIC_AUTH_QUERY_ENABLEDrestartDynamic lookup is disabled by default. Enabling it requires backend service credentials and a valid single-parameter query.
auth.auth_querystringSELECT usename, passwd FROM pg_shadow WHERE usename = $1--auth-queryPG_KINETIC_AUTH_QUERYrestartQuery must contain exactly one $1 placeholder. The lookup connection is dedicated to authentication and accepts SCRAM or MD5 verifier results only.
auth.auth_query_cache_ttl_msmilliseconds60000--auth-query-cache-ttl-msPG_KINETIC_AUTH_QUERY_CACHE_TTL_MSrestartSuccessful dynamic lookups are cached until this TTL expires. 0 disables cache hits.
auth.auth_failure_message_modeenumgeneric--auth-failure-message-modePG_KINETIC_AUTH_FAILURE_MESSAGE_MODErestartdetailed can expose more auth context to clients.
reload.config_fileoptional pathunset--config-filePG_KINETIC_CONFIG_FILErestartStartup/reload fails if file cannot read or parse.
reload.config_reload_interval_msmilliseconds5000--config-reload-interval-msPG_KINETIC_CONFIG_RELOAD_INTERVAL_MSrestartReload loop ticks at this interval.
reload.reload_enabledboolfalse--reload-enabledPG_KINETIC_CONFIG_RELOAD_ENABLEDrestartReload loop is disabled when false.
drain.drain_timeout_msmilliseconds30000--drain-timeout-msPG_KINETIC_DRAIN_TIMEOUT_MSrestartShutdown drain waits up to this duration.
drain.reject_new_clients_during_drainboolfalse--reject-new-clients-during-drainPG_KINETIC_REJECT_NEW_CLIENTS_DURING_DRAINrestartNew clients are rejected during drain when true.
health.health_addroptional socket addressunset--health-addrPG_KINETIC_HEALTH_ADDRrestartStartup fails if bind fails.
health.readiness_backend_check_interval_msmilliseconds1000--readiness-backend-check-interval-msPG_KINETIC_READINESS_BACKEND_CHECK_INTERVAL_MSrestartBackend health probe interval.
health.readiness_timeout_msmilliseconds5000--readiness-timeout-msPG_KINETIC_READINESS_TIMEOUT_MSrestartBackend health probe timeout.
socket.tcp_nodelaybooltrue--tcp-nodelayPG_KINETIC_TCP_NODELAYrestartSocket option failure follows strict mode behavior.
socket.tcp_keepaliveboolfalse--tcp-keepalivePG_KINETIC_TCP_KEEPALIVErestartEnables TCP keepalive when supported.
socket.tcp_keepalive_idle_msoptional millisecondsunset--tcp-keepalive-idle-msPG_KINETIC_TCP_KEEPALIVE_IDLE_MSrestartUnsupported values fail only in strict mode.
socket.tcp_keepalive_interval_msoptional millisecondsunset--tcp-keepalive-interval-msPG_KINETIC_TCP_KEEPALIVE_INTERVAL_MSrestartUnsupported values fail only in strict mode.
socket.tcp_keepalive_retriesoptional integerunset--tcp-keepalive-retriesPG_KINETIC_TCP_KEEPALIVE_RETRIESrestartUnsupported values fail only in strict mode.
socket.tcp_user_timeout_msoptional millisecondsunset--tcp-user-timeout-msPG_KINETIC_TCP_USER_TIMEOUT_MSrestartUnsupported values fail only in strict mode.
socket.tcp_send_buffer_bytesoptional bytesunset--tcp-send-buffer-bytesPG_KINETIC_TCP_SEND_BUFFER_BYTESrestartUnsupported values fail only in strict mode.
socket.tcp_recv_buffer_bytesoptional bytesunset--tcp-recv-buffer-bytesPG_KINETIC_TCP_RECV_BUFFER_BYTESrestartUnsupported values fail only in strict mode.
socket.strict_socket_option_modeboolfalse--strict-socket-option-modePG_KINETIC_STRICT_SOCKET_OPTION_MODErestartStartup fails on unsupported socket options when true.
resilience.breaker_failure_thresholdinteger5--breaker-failure-thresholdPG_KINETIC_BREAKER_FAILURE_THRESHOLDrestartConsecutive backend failures before opening the per-backend breaker.
resilience.breaker_cooldown_msmilliseconds5000--breaker-cooldown-msPG_KINETIC_BREAKER_COOLDOWN_MSrestartCooldown before one half-open recovery probe.
resilience.hedging_enabledboolfalse--hedging-enabledPG_KINETIC_HEDGING_ENABLEDrestartReserved safe read-hedge gate; duplicate backend forwarding remains disabled.
resilience.hedge_delay_msmilliseconds25--hedge-delay-msPG_KINETIC_HEDGE_DELAY_MSrestartDelay used by a future safe read-hedge executor.
resilience.failover_enabledboolfalse--failover-enabledPG_KINETIC_FAILOVER_ENABLEDrestartEnables one bounded retry for replay-safe reads when the backend is lost before any response bytes are sent.
resilience.failover_max_reconnect_msmilliseconds1000--failover-max-reconnect-msPG_KINETIC_FAILOVER_MAX_RECONNECT_MSrestartUpper bound for replacement backend checkout during transparent failover; also bounded by the current query timeout.
resilience.failover_replay_session_statebooltrue--failover-replay-session-statePG_KINETIC_FAILOVER_REPLAY_SESSION_STATErestartReplays tracked safe session settings such as application_name, search_path, timezone, datestyle, and extra_float_digits before retrying eligible reads.

The hedge fields are inactive reservation points. Setting resilience.hedging_enabled = true does not duplicate read forwarding in the current runtime. Use Transparent failover for the implemented retry behavior.

Runtime Lifecycle Fields

FieldTypeDefaultCLIEnvironmentReloadFailure mode
runtime.lifecycle.startup_grace_msmilliseconds30000--startup-grace-msPG_KINETIC_STARTUP_GRACE_MSrestartStartup coordination uses this timeout.
runtime.lifecycle.shutdown_grace_msmilliseconds30000--shutdown-grace-msPG_KINETIC_SHUTDOWN_GRACE_MSrestartShutdown coordination uses this timeout.
runtime.lifecycle.readiness_fail_during_drainbooltrue--readiness-fail-during-drainPG_KINETIC_READINESS_FAIL_DURING_DRAINrestart/readyz reports not ready during drain when true.
runtime.lifecycle.pre_stop_drain_enabledbooltrue--pre-stop-drain-enabledPG_KINETIC_PRE_STOP_DRAIN_ENABLEDrestartHTTP /drain is not implemented, so do not wire Kubernetes hooks to it yet.
runtime.lifecycle.pre_stop_drain_endpointstring/drain--pre-stop-drain-endpointPG_KINETIC_PRE_STOP_DRAIN_ENDPOINTrestartInformational until an HTTP drain endpoint exists.
runtime.lifecycle.startup_backend_checks_enabledbooltrue--startup-backend-checks-enabledPG_KINETIC_STARTUP_BACKEND_CHECKS_ENABLEDrestartStartup readiness depends on backend checks when true.
runtime.lifecycle.termination_grace_period_secondsseconds65--termination-grace-period-secondsPG_KINETIC_TERMINATION_GRACE_PERIOD_SECONDSrestartDocuments expected supervisor grace period.
runtime.node.node_idstringgenerated host/process id--node-idPG_KINETIC_NODE_IDrestartEmpty or invalid ids fail parse.
runtime.engine.runtime_engineenumthread_per_core--runtime-enginePG_KINETIC_RUNTIME_ENGINErestartValues are thread_per_core, tokio_default, tokio_current_thread, and io_uring.
runtime.engine.experimental_runtime_enabledboolfalse--experimental-runtime-enabledPG_KINETIC_EXPERIMENTAL_RUNTIME_ENABLEDrestartLegacy compatibility field; stable runtime engines do not require it.
runtime.engine.runtime_shardsoptional integerunset--runtime-shardsPG_KINETIC_RUNTIME_SHARDSrestartOverrides automatic runtime shard sizing; 0 fails validation.
runtime.production.control_plane_enabledboolfalse--control-plane-enabledPG_KINETIC_CONTROL_PLANE_ENABLEDrestartNo control-plane runtime is documented as production-ready.
runtime.production.mirroring_enabledboolfalse--mirroring-enabledPG_KINETIC_MIRRORING_ENABLEDrestartLive proxy still constructs a disabled mirror dispatcher.
runtime.production.adaptive_enabledboolfalse--adaptive-enabledPG_KINETIC_ADAPTIVE_ENABLEDrestartStarts recommendation/simulation controller when true.
runtime.production.pressure.enabledboolfalse--pressure-enabledPG_KINETIC_PRESSURE_ENABLEDrestartEnables PSI-driven dynamic route in-flight pressure limits.
runtime.production.pressure.cpu_high_pctfloat20.0--pressure-cpu-high-pctPG_KINETIC_PRESSURE_CPU_HIGH_PCTrestartCPU PSI some avg10 threshold; values must be finite and within 0.0..=100.0.
runtime.production.pressure.mem_high_pctfloat10.0--pressure-mem-high-pctPG_KINETIC_PRESSURE_MEM_HIGH_PCTrestartMemory PSI some avg10 threshold; values must be finite and within 0.0..=100.0.
runtime.production.pressure.min_in_flight_floorinteger1--pressure-min-in-flight-floorPG_KINETIC_PRESSURE_MIN_IN_FLIGHT_FLOORrestartLowest dynamic per-route in-flight limit when pressure is high; must be greater than zero.
runtime.production.pressure.window_msmilliseconds5000--pressure-window-msPG_KINETIC_PRESSURE_WINDOW_MSrestartPressure control tick window; must be greater than zero.
runtime.production.adaptive_modeenumrecommend--adaptive-modePG_KINETIC_ADAPTIVE_MODErestartValues are recommend and apply; apply mode records simulated apply outcomes only.
runtime.production.adaptive_window_msmilliseconds60000--adaptive-window-msPG_KINETIC_ADAPTIVE_WINDOW_MSrestartMust be greater than zero.
runtime.production.adaptive_min_confidencefloat0.8--adaptive-min-confidencePG_KINETIC_ADAPTIVE_MIN_CONFIDENCErestartMust be finite and within 0.0..=1.0.
runtime.production.adaptive_apply_enabledboolfalse--adaptive-apply-enabledPG_KINETIC_ADAPTIVE_APPLY_ENABLEDrestartRequired for adaptive_mode = "apply"; does not mutate live settings.
runtime.production.adaptive_apply_allowlistlist[]--adaptive-apply-allowlistPG_KINETIC_ADAPTIVE_APPLY_ALLOWLISTrestartRequired and duplicate-free for apply mode.
runtime.production.adaptive_max_change_percentinteger10--adaptive-max-change-percentPG_KINETIC_ADAPTIVE_MAX_CHANGE_PERCENTrestartMust be between 1 and 100.

The internal apply and guardrail wrappers are flattened by the parser. They are not TOML table names.

The top-level pool lifecycle settings are flattened in TOML and CLI parsing. They populate the internal pool_lifecycle fields max_size, min_idle, idle_timeout, and max_lifetime.

Reload compatibility is strict. Any runtime field change, including adaptive runtime scalar fields, is restart-required. Accepted reloads affect new client connections and reloadable assets such as auth user file contents or TLS certificate file contents at unchanged paths; they do not change existing sessions or already checked-out backends. Backend service credentials are resolved for each new backend authentication exchange, so rotating the injected environment value takes effect after idle backends are discarded or recycled.

Preview Configs Not In Main Runtime

[sharding], [policy], and [mirror] examples from preview docs are not part of the main live proxy config contract. Use the preview commands for those models:

pg-kinetic route-preview --config preview.toml --database app --user app --sql "select 1"
pg-kinetic policy-preview --config preview.toml --database app --user app --route primary --shard default --query-class read_candidate

Do not deploy sharding, policy, or mirroring config as live traffic configuration until the proxy runtime exposes and applies those configs.

Sharding preview fields:

FieldDefaultNotes
sharding_enabledfalseEnables the offline sharding model for route-preview.
multi_shard_policyrejectValues are reject, first_match, and fan_out.
route_map_reload_stricttrueRejects overlapping route maps without explicit priority.
route_preview_enabledfalseMarks preview intent; it does not activate live traffic sharding.
route_maps[]Array of route-map entries.
scoperequired per route mapScope object such as database_user, application_name, schema_table, or tenant_key.
strategyrequired per route mapStrategy object with kind hash, range, or list.
targetsrequired per route mapNon-empty list of primary or replicas targets.
priorityunsetRequired when route maps overlap.

Policy preview fields:

FieldDefaultNotes
policy_modedisabledValues include disabled, dry-run, and enforcement modes supported by the parser.
policy_files[]File references for policy documents.
inline_rules[]Inline policy rules for preview and model validation.
policy_idgenerated defaultRule identifier shown in audit and preview output.
hook_pointdefault policy hookHook point evaluated by the preview model.
actionrequired for inline rulesFlattened inline rule action such as allow, deny, require primary, require replica, route override, shard override, or wasm.
policy_audit.policy_audit_enabledtrueEnables audit event recording when policy paths run.
policy_audit.policy_audit_sample_rate1.0Audit sampling rate.
policy_wasm.policy_wasm_enabledfalseRequired before wasm policy actions are accepted.
policy_eval_timeout_msimplementation defaultPolicy evaluation timeout.
policy_max_context_bytesimplementation defaultRedacted policy context size cap.

Mirror preview fields:

FieldDefaultNotes
mirroring_enabledfalseTop-level mirror model flag. Live traffic mirroring is not active today.
mirror_modeoffMirror mode parser value.
mirror_timeout_ms100Mirror task timeout.
mirror_max_in_flight128In-flight mirror task cap.
target.addressunsetMirror target socket address.
target.isolatedfalseMarks the target as isolated from production.
safety.mirror_writes_enabledfalseAllows write mirroring only when explicitly set.
safety.mirror_transactions_enabledfalseAllows transaction mirroring only when explicitly set.
safety.mirror_copy_enabledfalseAllows COPY mirroring only when explicitly set.
safety.mirror_listen_notify_enabledfalseAllows LISTEN/NOTIFY mirroring only when explicitly set.
safety.mirror_temp_table_enabledfalseAllows temp-table mirroring only when explicitly set.
safety.mirror_session_mutation_enabledfalseAllows session-mutation mirroring only when explicitly set.
safety.mirror_require_isolated_targettrueRejects unsafe production-target reuse.
sampling.mirror_sample_rate0.0Mirror sample rate.

Secrets And TLS

  • Keep private keys readable only by the pg-kinetic process user.
  • Mount certificates and user files read-only.
  • Rotate backend passwords by changing the injected secret and recycling idle backends when backend_password_env_var_name is used; existing checked-out sessions are unchanged.
  • Use verify_full only with backend_ca_path and backend_server_name.
  • Use verify_client only with client cert, key, and CA paths present.

Validate Before Rollout

pg-kinetic preflight --config /etc/pg-kinetic/pg-kinetic.toml

Container:

docker run --rm \
-v "$PWD/pg-kinetic.toml:/etc/pg-kinetic/pg-kinetic.toml:ro" \
ghcr.io/hookwoods/pg-kinetic:latest \
preflight --config /etc/pg-kinetic/pg-kinetic.toml