powa-team / pg_stat_kcache

Gather statistics about physical disk access and CPU consumption done by backends.
Other
214 stars 24 forks source link

Cannot update either create extension on PG12.5 on CentOS "could not find function "pg_stat_kcache_2_2" #29

Closed banlex73 closed 3 years ago

banlex73 commented 3 years ago

Hello Where: Postgres 12.5 on CentOS7 What: Getting error when running ALTER EXTENSION UPDATE either CREATE EXTENTION could not find function "pg_stat_kcache_2_2" in file "/usr/pgsql-12/lib/pg_stat_kcache.so" How I installed it: as root git clone https://github.com/powa-team/pg_stat_kcache.git cd pg_statkcache make ``` gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC -I. -I./ -I/usr/pgsql-12/include/server -I/usr/pgsql-12/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include -c -o pg_stat_kcache.o pg_stat_kcache.c gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC -shared -o pg_stat_kcache.so pg_stat_kcache.o -L/usr/pgsql-12/lib -Wl,--as-needed -L/usr/lib64/llvm5.0/lib -L/usr/lib64 -Wl,--as-needed -Wl,-rpath,'/usr/pgsql-12/lib',--enable-new-dtags /opt/rh/llvm-toolset-7/root/usr/bin/clang -Wno-ignored-attributes -fno-strict-aliasing -fwrapv -O2 -I. -I./ -I/usr/pgsql-12/include/server -I/usr/pgsql-12/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include -flto=thin -emit-llvm -c -o pg_stat_kcache.bc pg_stat_kcache.c


**make install**
`_/bin/mkdir -p '/usr/pgsql-12/lib'
/bin/mkdir -p '/usr/pgsql-12/share/extension'
/bin/mkdir -p '/usr/pgsql-12/share/extension'
/bin/install -c -m 755  pg_stat_kcache.so '/usr/pgsql-12/lib/pg_stat_kcache.so'
/bin/install -c -m 644 .//pg_stat_kcache.control '/usr/pgsql-12/share/extension/'
/bin/install -c -m 644 .//pg_stat_kcache--2.1.1.sql .//pg_stat_kcache--2.2.0.sql .//pg_stat_kcache--2.1.2--2.1.3.sql .//pg_stat_kcache--2.1.0.sql .//pg_stat_kcache--2.1.1--2.1.2.sql .//pg_stat_kcache--2.1.0--2.1.1.sql .//pg_stat_kcache--2.1.3--2.2.0.sql .//pg_stat_kcache--2.1.2.sql .//pg_stat_kcache--2.1.3.sql  '/usr/pgsql-12/share/extension/'
/bin/mkdir -p '/usr/pgsql-12/lib/bitcode/pg_stat_kcache'
/bin/mkdir -p '/usr/pgsql-12/lib/bitcode'/pg_stat_kcache/
/bin/install -c -m 644 pg_stat_kcache.bc '/usr/pgsql-12/lib/bitcode'/pg_stat_kcache/./
cd '/usr/pgsql-12/lib/bitcode' && /usr/lib64/llvm5.0/bin/llvm-lto -thinlto -thinlto-action=thinlink -o pg_stat_kcache.index.bc pg_stat_kcache/pg_stat_kcache.bc_`

su - postgres -c "psql -dpowa -c 'create extension pg_stat_kcache'"
**ERROR:  could not find function "pg_stat_kcache_2_2" in file "/usr/pgsql-12/lib/pg_stat_kcache.so"**

Same error when I was trying to **alter extension pg_stat_kcache update;**
`ERROR:  could not find function "pg_stat_kcache_2_2" in file "/usr/pgsql-12/lib/pg_stat_kcache.so"
powa=# select * from pg_available_extensions where name ='pg_stat_kcache';

      name      | default_version | installed_version |           comment
----------------+-----------------+-------------------+-----------------------------
 pg_stat_kcache | 2.2.0           | 2.1.3             | Kernel statistics gathering
(1 row)`

Please advice if I can provide anything else.

Thank you in advance
Andriy
rjuju commented 3 years ago

Hello,

The pg_stat_kcache_2_2 function is new to version 2.2, and is there to avoid a crash when trying to update the extension without restarting the server first to have the new shared library loaded, which is what you just tried.

A simple restart of the postgres server should allow you to perform the update.

banlex73 commented 3 years ago

Hello Julien really appreciate your swift response. All good now, did as you suggested, restarted the cluster and got it updated!

postgres=# select * from pg_available_extensions where name in ('powa','pg_stat_kcache'); name | default_version | installed_version | comment ----------------+-----------------+-------------------+----------------------------------- powa | 4.1.1 | 4.1.1 | PostgreSQL Workload Analyser-core pg_stat_kcache | 2.2.0 | 2.1.3 | Kernel statistics gathering (2 rows)

postgres=# postgres=# \q [postgres@postgres-dev-uscentral1-nascheduler0-0: ~]$ pg_ctl restart -D /pgsql/cluster/data/ waiting for server to shut down..... done server stopped waiting for server to start....2020-12-14 03:04:14.545 UTC [1773] (user=) (db=) (rhost=) (app=) [vxid: txid:0] [] WARNING: unrecognized configuration parameter "powa.database" 2020-12-14 03:04:14.546 UTC [1773] (user=) (db=) (rhost=) (app=) [vxid: txid:0] [] LOG: Auto detecting pg_stat_kcache.linux_hz parameter... 2020-12-14 03:04:14.546 UTC [1773] (user=) (db=) (rhost=) (app=) [vxid: txid:0] [] LOG: pg_stat_kcache.linux_hz is set to 1000000 2020-12-14 03:04:14.557 UTC [1773] (user=) (db=) (rhost=) (app=) [vxid: txid:0] [] LOG: listening on IPv4 address "0.0.0.0", port 5432 2020-12-14 03:04:14.557 UTC [1773] (user=) (db=) (rhost=) (app=) [vxid: txid:0] [] LOG: listening on IPv6 address "::", port 5432 2020-12-14 03:04:14.560 UTC [1773] (user=) (db=) (rhost=) (app=) [vxid: txid:0] [] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2020-12-14 03:04:14.565 UTC [1773] (user=) (db=) (rhost=) (app=) [vxid: txid:0] [] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432" ..2020-12-14 03:04:16.266 UTC [1773] (user=) (db=) (rhost=) (app=) [vxid: txid:0] [] LOG: could not read pg_stat_kcache file "pg_stat/pg_stat_kcache.stat": No such file or directory 2020-12-14 03:04:16.275 UTC [1773] (user=) (db=) (rhost=) (app=) [vxid: txid:0] [] LOG: redirecting log output to logging collector process 2020-12-14 03:04:16.275 UTC [1773] (user=) (db=) (rhost=) (app=) [vxid: txid:0] [] HINT: Future log output will appear in directory "/pgsql/cluster/log". done server started [postgres@postgres-dev-uscentral1-nascheduler0-0: ~]$ psql -c "alter extension pg_stat_kcache update" ALTER EXTENSION [postgres@postgres-dev-uscentral1-nascheduler0-0: ~]$ psql -c "select from pg_available_extensions where name in ('powa','pg_stat_kcache');" name | default_version | installed_version | comment ----------------+-----------------+-------------------+----------------------------------- powa | 4.1.1 | 4.1.1 | PostgreSQL Workload Analyser-core pg_stat_kcache | 2.2.0 | 2.2.0* | Kernel statistics gathering (2 rows)

нд, 13 груд. 2020 о 18:19 Julien Rouhaud notifications@github.com пише:

Hello,

The pg_stat_kcache_2_2 function is new to version 2.2, and is there to avoid a crash when trying to update the extension without restarting the server first to have the new shared library loaded, which is what you just tried.

A simple restart of the postgres server should allow you to perform the update.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/powa-team/pg_stat_kcache/issues/29#issuecomment-744124651, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIHWEYAVGHF3XKSJIVQLL6DSUVYZ3ANCNFSM4UZ2P27Q .

rjuju commented 3 years ago

Good news! I'll add some documentation to specify that a postgres restart can be required (usually for a minor version change).