https://bugzilla.redhat.com/show_bug.cgi?id=1997378
--- Comment #9 from mkulik(a)redhat.com ---
All packages seems to work correctly. I wrote short HOWTO to setup and test
basic functionality of pg_auto_failover and JIT extension for it:
######################
# pg_auto_failover #
# Setup & test HOWTO #
######################
# First we need to install pg_auto_failover
# postgres will be installed automatically as dependency
# RPMs links can be found above
dnf install pg_auto_failover-1.6.1-1.fc34.x86_64.rpm
dnf install pg_auto_failover-llvmjit-1.6.1-1.fc34.x86_64.rpm
# Let's create default database (we are not gonna use it)
postgresql-setup --initdb
# Let's try to start postgres server
systemctl start postgresql
# Let's install screen, we will use it later
dnf install -y screen
# JIT should be enabled by default after -llvmjit installation (Default ON
since postgresql version 12)
su postgres
psql
SHOW jit;
# When we su to another account (postgres) from root we need to adjust this
variables
export XDG_RUNTIME_DIR="/run/user/26" # <-- make sure ID
is correct (postgres user)
# make sure that root directories in PATH after su are
gone
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
# Let's setup DIRs for monitor node
export PGDATA=/tmp/monitor
export PGPORT=5000
##################################
# pg_auto_failover setup monitor
##################################
# let's open screen session (as postgres user)
screen
# adjust variables
export PGDATA=/tmp/monitor
export PGPORT=5000
> export XDG_RUNTIME_DIR="/run/user/26"
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
# create monitor instance
pg_autoctl create monitor --ssl-self-signed --hostname localhost
--auth trust --run
# detach screen CTRL +a +d
##################################
# pg_auto_failover setup node 1
##################################
# let's open another screen session for node 1 ( postgres user )
screen
# adjust variables
> export XDG_RUNTIME_DIR="/run/user/26"
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
> export PGDATA=/tmp/node_1
> export PGPORT=5001
# create node_1 instance
pg_autoctl create postgres \
--hostname localhost \
--auth trust \
--ssl-self-signed \
--monitor
'postgres://autoctl_node@localhost:5000/pg_auto_failover?sslmode=require' \
--run
# detach screen CTRL +a +d
##################################
# pg_auto_failover setup node 2
##################################
# let's open another screen session for node 2 (postgres user)
screen
# adjust variables
> export XDG_RUNTIME_DIR="/run/user/26"
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
> export PGDATA=/tmp/node_2
> export PGPORT=5002
# create node_2 instance
pg_autoctl create postgres \
--hostname localhost \
--auth trust \
--ssl-self-signed \
--monitor
'postgres://autoctl_node@localhost:5000/pg_auto_failover?sslmode=require' \
--run
# detach screen CTRL +a +d
# Now all is setup and we can test pg_auto_failover from postgres user
# We need to remember to adjust all variables when we use su (this can be
automated in init scripts)
# Example commands to test:
pg_autoctl show state
pg_autoctl perform switchover
Result:
$ pg_autoctl show state
Name | Node | Host:Port | LSN | Reachable | Current State |
Assigned State
-------+-------+----------------+-----------+-----------+---------------------+--------------------
node_1 | 1 | localhost:5001 | 0/30000D8 | yes | primary |
primary
node_2 | 2 | localhost:5002 | 0/30000D8 | yes | secondary |
secondary
# Testing JIT extension require some changes.
# We need to fake one thing because running JIT is not really fast/optimal in
most scenarios:
# we need to change config settings in postgresql monitor node ( for example )
# to force postgres to use JIT when looking at cost of a Query.
# We have 2 options to do that.
##########
# OPTION 1
##########
# Edit postgres configuration file in /tmp/monitor
# Change this options:
# jit_above_cost = 1
# jit_inline_above_cost = 1
# jit_optimize_above_cost = 1
# After setting this up we need to resume screen with monitor
# and rerun it.
screen -r <pid monitor>
# To kill current command:
CTRL+C
# rerun the same command
# Proper command here would be probably: pg_autoctl start monitor
# but this is fine to ( it will skip creating)
pg_autoctl create monitor --ssl-self-signed --hostname localhost
--auth trust --run
##########
# OPTION 2
##########
# Execute as postgres user
psql -h localhost -p 5000
set jit = on;
set jit_above_cost = 1;
set jit_inline_above_cost = 1;
set jit_optimize_above_cost = 1;
# Do not close connection, otherwise this settings will be lost
# Here we should be still connected to monitor postgres node after option 2 (
via psql )
# if we choose option 1 we need to connect to it:
psql -h localhost -p 5000
# Lets create pg_auto_failover extension
CREATE EXTENSION pgautofailover CASCADE;
# Let's try to execute any command with pg_auto_failover function with analyze:
explain analyze select * from pgautofailover.get_nodes();
# Expected result:
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------
Function Scan on get_nodes (cost=0.00..10.00 rows=1000 width=85) (actual
time=850.328..850.328 rows=0 loops=1)
Planning Time: 0.033 ms
JIT:
Functions: 2
Options: Inlining true, Optimization true, Expressions true, Deforming true
Timing: Generation 0.653 ms, Inlining 0.085 ms, Optimization 3.543 ms, Emission 8.198
ms, Total 12.478 ms
Execution Time: 851.127 ms
(7 rows)
--
You are receiving this mail because:
You are always notified about changes to this product and component
You are on the CC list for the bug.