powa-team/pg_stat_kcache

unknown type name «LWLock»

Closed this issue · 7 comments

OS: Centos 7
DB: PostgreSQL 12

Hi! I am getting error while trying to compile extension. Installed pg_config from postgresql-devel.
When I do "make", C errors occur. Compiler can't find type LWLock, and then it tells that function arguments does not match.
Command line:

[admin@localhost pg_stat_kcache-REL2_2_1]$ make
gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -DLINUX_OOM_SCORE_ADJ=0 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -fPIC -I. -I. -I/usr/include/pgsql/server -I/usr/include/pgsql/internal -D_GNU_SOURCE -I/usr/include/libxml2   -c -o pg_stat_kcache.o pg_stat_kcache.c
pg_stat_kcache.c:130:2: ошибка: unknown type name «LWLock»
  LWLock    *lock;     /* protects hashtable search/modification */
  ^
...
...
pg_stat_kcache.c:1297:2: ошибка: несовместимый тип аргумента 1 функции «LWLockRelease»
  LWLockRelease(pgsk->lock);

  ^
In file included from /usr/include/pgsql/server/storage/lock.h:18:0,
                 from /usr/include/pgsql/server/access/genam.h:20,
                 from /usr/include/pgsql/server/access/hash.h:20,
                 from pg_stat_kcache.c:29:
/usr/include/pgsql/server/storage/lwlock.h:112:13: замечание: expected «LWLockId» but argument is of type «int *»
 extern void LWLockRelease(LWLockId lockid);
             ^
make: *** [pg_stat_kcache.o] Ошибка 1

Attached two files, full text of make errors and pg_config.

make_error.txt
pg_config.txt

rjuju commented

Hi,

According to the pg_config output:

VERSION = PostgreSQL 9.2.24

Somehow you're pointing to a very old server version headers, not pg12, which probably explain your problem.

I don't know how you installed postgres and the development files, but you have a mismatch between your wanted PG 12 version and the pg_config version you're actually using and compiling against.

I have never compiled extensions before, maybe I installed the devpack badly. After installing the PostgreSQL server, pg_config was not available. I found a recommendation in Google to download the postgresql-devel package (stackoverflow). Installing postgresql-devel gives this version of pg_config. But thanks for the answer, I'll try to solve the problem. In general, it would be cool if the extension existed in compiled form

rjuju commented

Unfortunately It's hard to help with that few information, I don't know which command you used, how you installed postgres, in which path the packages installed stuff and so on.

Note that the extension is available in compiled form through the PGDG repository at https://yum.postgresql.org/, although I'm not sure it would play well if you installed postgres from the centos repository.

I installed PG from the offical repo (repo), before that excluding from centos repo. PG server exactly 12 version. But thank's you for the information! I'll try to figure it out. If I solve the problem, I'll let you know. Probably postgresql-devel should be excluded from centos repos too. In general, you can close the issue.

For some reason, the PATH for pg_config was not set by default. I added it manually now everything works.

rjuju commented

Great news, thanks for the confirmation.

Note that since you're installing postgres from the PGDG repository, it's recommended to get the packaged version of pg_stat_kcache there too, with a simple yum / dnf install rather than compiling it yourself.

Yeap, it was much easier to just install compiled from repo. Unfortunately, I didnt found this the first time. Now I do only yum install, thank you!

sudo yum install pg_stat_kcache_12