Timescaledb: Installer installs wrong library version (tsdb 0.8.0 from source, debian jessie, postgres 9.6)

Created on 13 Jan 2018  路  6Comments  路  Source: timescale/timescaledb

We've been testing out timescaledb via docker for a few months, and now we'd like to move to production and install on bare metal.

Unfortunately, there aren't any packages available for debian, so I'm trying to install from source. I'm able to run through the install process successfully, however when I restart postgres after installing the extension I get the following error:

2018-01-12 16:37:42.347 PST [4801] FATAL:  incompatible library "/usr/lib/postgresql/9.6/lib/timescaledb.so": version mismatch
2018-01-12 16:37:42.347 PST [4801] DETAIL:  Server is version 9.6, library is version 10.0.
2018-01-12 16:37:42.347 PST [4801] LOG:  database system is shut down

Which is really weird because a) I only have postgres 9.6 installed on this machine, and b) when i ran the bootstrap script to setup the install, it said that it would install against 9.6. There are some warnings during make that look like they're associated with the problem though (see below).


Full log

System information:

$ uname -a
Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1+deb8u2 (2017-03-07) x86_64 GNU/Linux
$ cat /etc/issue
Debian GNU/Linux 8 \n \l

Installed packages:

$ dpkg -l | grep postgres
ii  pgdg-keyring                     2017.3                     all          keyring for apt.postgresql.org
ii  postgresql-9.6                   9.6.6-1.pgdg80+1           amd64        object-relational SQL database, version 9.6 server
ii  postgresql-client-9.6            9.6.6-1.pgdg80+1           amd64        front-end programs for PostgreSQL 9.6
ii  postgresql-client-common         189.pgdg80+2               all          manager for multiple PostgreSQL client versions
ii  postgresql-common                189.pgdg80+2               all          PostgreSQL database-cluster manager
ii  postgresql-contrib-9.6           9.6.6-1.pgdg80+1           amd64        additional facilities for PostgreSQL
ii  postgresql-server-dev-9.6        9.6.6-1.pgdg80+1           amd64        development files for PostgreSQL 9.6 server-side programming

Output from pg_config:

/tmp/timescaledb $ pg_config
BINDIR = /usr/lib/postgresql/9.6/bin
DOCDIR = /usr/share/doc/postgresql-doc-9.6
HTMLDIR = /usr/share/doc/postgresql-doc-9.6
INCLUDEDIR = /usr/include/postgresql
PKGINCLUDEDIR = /usr/include/postgresql
INCLUDEDIR-SERVER = /usr/include/postgresql/9.6/server
LIBDIR = /usr/lib/x86_64-linux-gnu
PKGLIBDIR = /usr/lib/postgresql/9.6/lib
LOCALEDIR = /usr/share/locale
MANDIR = /usr/share/postgresql/9.6/man
SHAREDIR = /usr/share/postgresql/9.6
SYSCONFDIR = /etc/postgresql-common
PGXS = /usr/lib/postgresql/9.6/lib/pgxs/src/makefiles/pgxs.mk
CONFIGURE = '--with-tcl' '--with-perl' '--with-python' '--with-pam' '--with-openssl' '--with-libxml' '--with-libxslt' '--with-tclconfig=/usr/lib/x86_64-linux-gnu/tcl8.6' '--with-includes=/usr/include/tcl8.6' 'PYTHON=/usr/bin/python' '--mandir=/usr/share/postgresql/9.6/man' '--docdir=/usr/share/doc/postgresql-doc-9.6' '--sysconfdir=/etc/postgresql-common' '--datarootdir=/usr/share/' '--datadir=/usr/share/postgresql/9.6' '--bindir=/usr/lib/postgresql/9.6/bin' '--libdir=/usr/lib/x86_64-linux-gnu/' '--libexecdir=/usr/lib/postgresql/' '--includedir=/usr/include/postgresql/' '--enable-nls' '--enable-integer-datetimes' '--enable-thread-safety' '--enable-tap-tests' '--enable-debug' '--disable-rpath' '--with-uuid=e2fs' '--with-gnu-ld' '--with-pgport=5432' '--with-system-tzdata=/usr/share/zoneinfo' '--with-systemd' 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fPIC -pie -fno-omit-frame-pointer' 'LDFLAGS=-Wl,-z,relro -Wl,-z,now' '--with-gssapi' '--with-ldap' '--with-includes=/usr/include/mit-krb5' '--with-libs=/usr/lib/mit-krb5' '--with-libs=/usr/lib/x86_64-linux-gnu/mit-krb5' '--with-selinux' 'CPPFLAGS=-D_FORTIFY_SOURCE=2'
CC = gcc
CPPFLAGS = -DFRONTEND -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include/mit-krb5
CFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fPIC -pie -fno-omit-frame-pointer
CFLAGS_SL = -fPIC
LDFLAGS = -L../../src/common -Wl,-z,relro -Wl,-z,now -L/usr/lib/x86_64-linux-gnu/mit-krb5 -Wl,--as-needed
LDFLAGS_EX = 
LDFLAGS_SL = 
LIBS = -lpgcommon -lpgport -lselinux -lxslt -lxml2 -lpam -lssl -lcrypto -lgssapi_krb5 -lz -ledit -lrt -lcrypt -ldl -lm  
VERSION = PostgreSQL 9.6.6

Checkout code:

/tmp $ git clone https://github.com/timescale/timescaledb.git 
Cloning into 'timescaledb'...
remote: Counting objects: 7821, done.
remote: Compressing objects: 100% (67/67), done.
remote: Total 7821 (delta 50), reused 46 (delta 28), pack-reused 7726
Receiving objects: 100% (7821/7821), 2.30 MiB | 0 bytes/s, done.
Resolving deltas: 100% (5912/5912), done.
Checking connectivity... done.

/tmp $ cd timescaledb/
/tmp/timescaledb $ git checkout 0.8.0
Note: checking out '0.8.0'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at 446b82e... Release 0.8.0

bootstrap and make (SEE WARNINGS BELOW):

/tmp/timescaledb $ export PATH=/tmp/cmake-3.10.1-Linux-x86_64/bin:$PATH
/tmp/timescaledb $ ./bootstrap 
-- The C compiler identification is GNU 4.9.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features

-- Detecting C compile features - done
-- TimescaleDB version 0.8.0. Can be updated from version 0.7.1
-- Build type is Release
-- Found Git: /usr/bin/git (found version "2.1.4") 
-- Using pg_config /usr/bin/pg_config
-- Compiling against PostgreSQL version 9.6.6
-- Using pg_regress /usr/lib/postgresql/9.6/lib/pgxs/src/test/regress/pg_regress
-- Using objdump /usr/bin/objdump
-- Install pgindent to be able to format C code: https://github.com/postgres/postgres/tree/master/src/tools/pgindent
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/timescaledb/build
TimescaleDB build system initialized in ./build. To compile, do:
cd ./build && make


/tmp/timescaledb/build $ make
Scanning dependencies of target sqlfile
[  2%] Generating timescaledb--0.8.0.sql
[  2%] Built target sqlfile
Scanning dependencies of target sqlupdatefile
[  4%] Generating timescaledb--0.7.1--0.8.0.sql
[  4%] Built target sqlupdatefile
[  6%] Generating gitcommit.h
Scanning dependencies of target timescaledb
[  8%] Building C object src/CMakeFiles/timescaledb.dir/agg_bookend.c.o
[ 10%] Building C object src/CMakeFiles/timescaledb.dir/cache.c.o
[ 13%] Building C object src/CMakeFiles/timescaledb.dir/cache_invalidate.c.o
[ 15%] Building C object src/CMakeFiles/timescaledb.dir/catalog.c.o
[ 17%] Building C object src/CMakeFiles/timescaledb.dir/chunk.c.o
[ 19%] Building C object src/CMakeFiles/timescaledb.dir/chunk_constraint.c.o
[ 21%] Building C object src/CMakeFiles/timescaledb.dir/chunk_dispatch.c.o
[ 23%] Building C object src/CMakeFiles/timescaledb.dir/chunk_dispatch_info.c.o
[ 26%] Building C object src/CMakeFiles/timescaledb.dir/chunk_dispatch_plan.c.o
[ 28%] Building C object src/CMakeFiles/timescaledb.dir/chunk_dispatch_state.c.o
[ 30%] Building C object src/CMakeFiles/timescaledb.dir/chunk_index.c.o
[ 32%] Building C object src/CMakeFiles/timescaledb.dir/chunk_insert_state.c.o
[ 34%] Building C object src/CMakeFiles/timescaledb.dir/compat.c.o
[ 36%] Building C object src/CMakeFiles/timescaledb.dir/constraint_aware_append.c.o
[ 39%] Building C object src/CMakeFiles/timescaledb.dir/copy.c.o
[ 41%] Building C object src/CMakeFiles/timescaledb.dir/dimension.c.o
[ 43%] Building C object src/CMakeFiles/timescaledb.dir/dimension_slice.c.o
[ 45%] Building C object src/CMakeFiles/timescaledb.dir/dimension_vector.c.o
[ 47%] Building C object src/CMakeFiles/timescaledb.dir/event_trigger.c.o
[ 50%] Building C object src/CMakeFiles/timescaledb.dir/executor.c.o
[ 52%] Building C object src/CMakeFiles/timescaledb.dir/extension.c.o
[ 54%] Building C object src/CMakeFiles/timescaledb.dir/guc.c.o
[ 56%] Building C object src/CMakeFiles/timescaledb.dir/histogram.c.o
[ 58%] Building C object src/CMakeFiles/timescaledb.dir/hypercube.c.o
[ 60%] Building C object src/CMakeFiles/timescaledb.dir/hypertable.c.o
[ 63%] Building C object src/CMakeFiles/timescaledb.dir/hypertable_cache.c.o
[ 65%] Building C object src/CMakeFiles/timescaledb.dir/hypertable_insert.c.o
[ 67%] Building C object src/CMakeFiles/timescaledb.dir/indexing.c.o
[ 69%] Building C object src/CMakeFiles/timescaledb.dir/init.c.o
In file included from /tmp/timescaledb/src/init.c:2:0:
/usr/include/postgresql/pg_config.h:724:0: warning: "PACKAGE_STRING" redefined
 #define PACKAGE_STRING "PostgreSQL 10.1"
 ^
In file included from /usr/include/postgresql/9.6/server/c.h:53:0,
                 from /usr/include/postgresql/9.6/server/postgres.h:47,
                 from /tmp/timescaledb/src/init.c:1:
/usr/include/postgresql/9.6/server/pg_config.h:730:0: note: this is the location of the previous definition
 #define PACKAGE_STRING "PostgreSQL 9.6.6"
 ^
In file included from /tmp/timescaledb/src/init.c:2:0:
/usr/include/postgresql/pg_config.h:733:0: warning: "PACKAGE_VERSION" redefined
 #define PACKAGE_VERSION "10.1"
 ^
In file included from /usr/include/postgresql/9.6/server/c.h:53:0,
                 from /usr/include/postgresql/9.6/server/postgres.h:47,
                 from /tmp/timescaledb/src/init.c:1:
/usr/include/postgresql/9.6/server/pg_config.h:739:0: note: this is the location of the previous definition
 #define PACKAGE_VERSION "9.6.6"
 ^
In file included from /tmp/timescaledb/src/init.c:2:0:
/usr/include/postgresql/pg_config.h:746:0: warning: "PG_MAJORVERSION" redefined
 #define PG_MAJORVERSION "10"
 ^
In file included from /usr/include/postgresql/9.6/server/c.h:53:0,
                 from /usr/include/postgresql/9.6/server/postgres.h:47,
                 from /tmp/timescaledb/src/init.c:1:
/usr/include/postgresql/9.6/server/pg_config.h:752:0: note: this is the location of the previous definition
 #define PG_MAJORVERSION "9.6"
 ^
In file included from /tmp/timescaledb/src/init.c:2:0:
/usr/include/postgresql/pg_config.h:752:0: warning: "PG_VERSION" redefined
 #define PG_VERSION "10.1"
 ^
In file included from /usr/include/postgresql/9.6/server/c.h:53:0,
                 from /usr/include/postgresql/9.6/server/postgres.h:47,
                 from /tmp/timescaledb/src/init.c:1:
/usr/include/postgresql/9.6/server/pg_config.h:758:0: note: this is the location of the previous definition
 #define PG_VERSION "9.6.6"
 ^
In file included from /tmp/timescaledb/src/init.c:2:0:
/usr/include/postgresql/pg_config.h:755:0: warning: "PG_VERSION_NUM" redefined
 #define PG_VERSION_NUM 100001
 ^
In file included from /usr/include/postgresql/9.6/server/c.h:53:0,
                 from /usr/include/postgresql/9.6/server/postgres.h:47,
                 from /tmp/timescaledb/src/init.c:1:
/usr/include/postgresql/9.6/server/pg_config.h:761:0: note: this is the location of the previous definition
 #define PG_VERSION_NUM 90606
 ^
In file included from /tmp/timescaledb/src/init.c:2:0:
/usr/include/postgresql/pg_config.h:758:0: warning: "PG_VERSION_STR" redefined
 #define PG_VERSION_STR "PostgreSQL 10.1 on x86_64-pc-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit"
 ^
In file included from /usr/include/postgresql/9.6/server/c.h:53:0,
                 from /usr/include/postgresql/9.6/server/postgres.h:47,
                 from /tmp/timescaledb/src/init.c:1:
/usr/include/postgresql/9.6/server/pg_config.h:764:0: note: this is the location of the previous definition
 #define PG_VERSION_STR "PostgreSQL 9.6.6 on x86_64-pc-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit"
 ^
[ 71%] Building C object src/CMakeFiles/timescaledb.dir/parse_analyze.c.o
[ 73%] Building C object src/CMakeFiles/timescaledb.dir/parse_rewrite.c.o
[ 76%] Building C object src/CMakeFiles/timescaledb.dir/partitioning.c.o
[ 78%] Building C object src/CMakeFiles/timescaledb.dir/planner.c.o
[ 80%] Building C object src/CMakeFiles/timescaledb.dir/planner_utils.c.o
[ 82%] Building C object src/CMakeFiles/timescaledb.dir/process_utility.c.o
[ 84%] Building C object src/CMakeFiles/timescaledb.dir/scanner.c.o
[ 86%] Building C object src/CMakeFiles/timescaledb.dir/sort_transform.c.o
[ 89%] Building C object src/CMakeFiles/timescaledb.dir/subspace_store.c.o
[ 91%] Building C object src/CMakeFiles/timescaledb.dir/tablespace.c.o
[ 93%] Building C object src/CMakeFiles/timescaledb.dir/trigger.c.o
[ 95%] Building C object src/CMakeFiles/timescaledb.dir/utils.c.o
[ 97%] Building C object src/CMakeFiles/timescaledb.dir/version.c.o
[100%] Linking C shared module timescaledb.so
[100%] Built target timescaledb

install and restart postgres:

/tmp/timescaledb/build $ make install
[  2%] Built target sqlfile
[  4%] Built target sqlupdatefile
[100%] Built target timescaledb
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/share/postgresql/9.6/extension/timescaledb.control
-- Installing: /usr/share/postgresql/9.6/extension/timescaledb--0.8.0.sql
-- Installing: /usr/share/postgresql/9.6/extension/timescaledb--0.7.1--0.8.0.sql
-- Installing: /usr/share/postgresql/9.6/extension/timescaledb--0.1.0--0.2.0.sql
-- Installing: /usr/share/postgresql/9.6/extension/timescaledb--0.2.0--0.3.0.sql
-- Installing: /usr/share/postgresql/9.6/extension/timescaledb--0.3.0--0.4.0.sql
-- Installing: /usr/share/postgresql/9.6/extension/timescaledb--0.4.0--0.4.1.sql
-- Installing: /usr/share/postgresql/9.6/extension/timescaledb--0.4.1--0.4.2.sql
-- Installing: /usr/share/postgresql/9.6/extension/timescaledb--0.4.2--0.5.0.sql
-- Installing: /usr/share/postgresql/9.6/extension/timescaledb--0.5.0--0.6.0.sql
-- Installing: /usr/share/postgresql/9.6/extension/timescaledb--0.6.0--0.6.1.sql
-- Installing: /usr/share/postgresql/9.6/extension/timescaledb--0.6.1--0.7.0.sql
-- Installing: /usr/share/postgresql/9.6/extension/timescaledb--0.6.1--0.7.1.sql
-- Installing: /usr/share/postgresql/9.6/extension/timescaledb--0.7.0--0.7.1.sql
-- Installing: /usr/lib/postgresql/9.6/lib/timescaledb.so


/tmp/timescaledb/build $ service postgresql restart
/tmp/timescaledb/build $ cat /var/log/postgresql/postgresql-9.6-main.log 
2018-01-12 15:52:38.424 PST [20897] LOG:  database system was shut down at 2018-01-12 15:52:37 PST
2018-01-12 15:52:38.432 PST [20897] LOG:  MultiXact member wraparound protections are now enabled
2018-01-12 15:52:38.434 PST [20896] LOG:  database system is ready to accept connections
2018-01-12 15:52:38.435 PST [20901] LOG:  autovacuum launcher started
2018-01-12 15:52:38.900 PST [20903] [unknown]@[unknown] LOG:  incomplete startup packet
2018-01-12 16:30:32.528 PST [20896] LOG:  received fast shutdown request
2018-01-12 16:30:32.528 PST [20896] LOG:  aborting any active transactions
2018-01-12 16:30:32.528 PST [20901] LOG:  autovacuum launcher shutting down
2018-01-12 16:30:32.529 PST [20898] LOG:  shutting down
2018-01-12 16:30:32.543 PST [20896] LOG:  database system is shut down
2018-01-12 16:30:33.619 PST [3914] FATAL:  incompatible library "/usr/lib/postgresql/9.6/lib/timescaledb.so": version mismatch
2018-01-12 16:30:33.619 PST [3914] DETAIL:  Server is version 9.6, library is version 10.0.
2018-01-12 16:30:33.619 PST [3914] LOG:  database system is shut down
2018-01-12 16:37:42.347 PST [4801] FATAL:  incompatible library "/usr/lib/postgresql/9.6/lib/timescaledb.so": version mismatch
2018-01-12 16:37:42.347 PST [4801] DETAIL:  Server is version 9.6, library is version 10.0.
2018-01-12 16:37:42.347 PST [4801] LOG:  database system is shut down
2018-01-12 17:05:06.743 PST [6260] FATAL:  incompatible library "/usr/lib/postgresql/9.6/lib/timescaledb.so": version mismatch
2018-01-12 17:05:06.743 PST [6260] DETAIL:  Server is version 9.6, library is version 10.0.
2018-01-12 17:05:06.743 PST [6260] LOG:  database system is shut down

Most helpful comment

Looking at this further, I think it might be a problem with the postgresql-server-dev-9.6 package in debian jessie. There's a conflict between the PG_VERSION listed in /usr/include/postgresql/9.6/server/pg_config.h and /usr/include/postgresql/pg_config.h.

I googled around and couldn't find this logged as a bug anywhere, which I find strange. But I can replicate by creating a docker container from jessie and one from stretch -- in jessie there's a conflict and in stretch the PG_VERSIONs match up.


Using jessie:

FROM debian:jessie

RUN apt-get update && \
  apt-get install -y wget ca-certificates && \
  echo "deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
  wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
  apt-get update && \
  apt-get install -y postgresql-9.6 postgresql-server-dev-9.6
root@8e958f2f9813:/usr/include/postgresql# grep -r PG_VERSION *
9.6/server/pg_config.h:#define PG_VERSION "9.6.6"
9.6/server/pg_config.h:#define PG_VERSION_NUM 90606
9.6/server/pg_config.h:#define PG_VERSION_STR "PostgreSQL 9.6.6 on x86_64-pc-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit"
9.6/server/fmgr.h:  PG_VERSION_NUM / 100, \
9.6/server/catalog/catversion.h: * stored in PG_VERSION.  It shouldn't matter to end users, but during
9.6/server/miscadmin.h:#define PG_BACKEND_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n"
internal/port.h:#define PG_BACKEND_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n"
pg_config.h:#define PG_VERSION "10.1"
pg_config.h:#define PG_VERSION_NUM 100001
pg_config.h:#define PG_VERSION_STR "PostgreSQL 10.1 on x86_64-pc-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit"

Using stretch:

FROM debian:stretch

RUN apt-get update && apt-get install -y postgresql-9.6 postgresql-server-dev-9.6
root@a26f3f9c459d:/usr/include/postgresql# grep -r PG_VERSION *
9.6/server/pg_config.h:#define PG_VERSION "9.6.6"
9.6/server/pg_config.h:#define PG_VERSION_NUM 90606
9.6/server/pg_config.h:#define PG_VERSION_STR "PostgreSQL 9.6.6 on x86_64-pc-linux-gnu, compiled by gcc (Debian 6.3.0-18) 6.3.0 20170516, 64-bit"
9.6/server/fmgr.h:  PG_VERSION_NUM / 100, \
9.6/server/catalog/catversion.h: * stored in PG_VERSION.  It shouldn't matter to end users, but during
9.6/server/miscadmin.h:#define PG_BACKEND_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n"
pg_config.h:#define PG_VERSION "9.6.6"
pg_config.h:#define PG_VERSION_NUM 90606
pg_config.h:#define PG_VERSION_STR "PostgreSQL 9.6.6 on x86_64-pc-linux-gnu, compiled by gcc (Debian 6.3.0-18) 6.3.0 20170516, 64-bit"

root@40007e4dd6c4:/usr/include/postgresql# diff 9.6/server/pg_config.h pg_config.h
# no difference!

I don't have experience building against postgres dev, so I'm not sure why these files are duplicated on the server in the first place, or if it's abnormal to have discrepancies like this.

Seems like the right choice is to upgrade to stretch, though that's not possible for me as an immediate fix.

So in the meantime I removed the header files under /usr/include/postgresql, just leaving the ones under /usr/include/postgresql/9.6/server/, and timescaledb can build, install, and run with no warnings or errors. Unclear how irresponsible this is, but we're at an early testing stage at this point...

Anyway, this doesn't sound like a timescaledb problem, so closing this out.

All 6 comments

It appears something is going wrong during compilation given all the warnings you're seeing (it should compile without warnings). We haven't tried compiling on gcc versions older than the 5-series. Is it possible for you to update gcc?

We can look more into why that compiler might be having trouble with our code, but it is a relatively old version of GCC.

Looking at this further, I think it might be a problem with the postgresql-server-dev-9.6 package in debian jessie. There's a conflict between the PG_VERSION listed in /usr/include/postgresql/9.6/server/pg_config.h and /usr/include/postgresql/pg_config.h.

I googled around and couldn't find this logged as a bug anywhere, which I find strange. But I can replicate by creating a docker container from jessie and one from stretch -- in jessie there's a conflict and in stretch the PG_VERSIONs match up.


Using jessie:

FROM debian:jessie

RUN apt-get update && \
  apt-get install -y wget ca-certificates && \
  echo "deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
  wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
  apt-get update && \
  apt-get install -y postgresql-9.6 postgresql-server-dev-9.6
root@8e958f2f9813:/usr/include/postgresql# grep -r PG_VERSION *
9.6/server/pg_config.h:#define PG_VERSION "9.6.6"
9.6/server/pg_config.h:#define PG_VERSION_NUM 90606
9.6/server/pg_config.h:#define PG_VERSION_STR "PostgreSQL 9.6.6 on x86_64-pc-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit"
9.6/server/fmgr.h:  PG_VERSION_NUM / 100, \
9.6/server/catalog/catversion.h: * stored in PG_VERSION.  It shouldn't matter to end users, but during
9.6/server/miscadmin.h:#define PG_BACKEND_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n"
internal/port.h:#define PG_BACKEND_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n"
pg_config.h:#define PG_VERSION "10.1"
pg_config.h:#define PG_VERSION_NUM 100001
pg_config.h:#define PG_VERSION_STR "PostgreSQL 10.1 on x86_64-pc-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit"

Using stretch:

FROM debian:stretch

RUN apt-get update && apt-get install -y postgresql-9.6 postgresql-server-dev-9.6
root@a26f3f9c459d:/usr/include/postgresql# grep -r PG_VERSION *
9.6/server/pg_config.h:#define PG_VERSION "9.6.6"
9.6/server/pg_config.h:#define PG_VERSION_NUM 90606
9.6/server/pg_config.h:#define PG_VERSION_STR "PostgreSQL 9.6.6 on x86_64-pc-linux-gnu, compiled by gcc (Debian 6.3.0-18) 6.3.0 20170516, 64-bit"
9.6/server/fmgr.h:  PG_VERSION_NUM / 100, \
9.6/server/catalog/catversion.h: * stored in PG_VERSION.  It shouldn't matter to end users, but during
9.6/server/miscadmin.h:#define PG_BACKEND_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n"
pg_config.h:#define PG_VERSION "9.6.6"
pg_config.h:#define PG_VERSION_NUM 90606
pg_config.h:#define PG_VERSION_STR "PostgreSQL 9.6.6 on x86_64-pc-linux-gnu, compiled by gcc (Debian 6.3.0-18) 6.3.0 20170516, 64-bit"

root@40007e4dd6c4:/usr/include/postgresql# diff 9.6/server/pg_config.h pg_config.h
# no difference!

I don't have experience building against postgres dev, so I'm not sure why these files are duplicated on the server in the first place, or if it's abnormal to have discrepancies like this.

Seems like the right choice is to upgrade to stretch, though that's not possible for me as an immediate fix.

So in the meantime I removed the header files under /usr/include/postgresql, just leaving the ones under /usr/include/postgresql/9.6/server/, and timescaledb can build, install, and run with no warnings or errors. Unclear how irresponsible this is, but we're at an early testing stage at this point...

Anyway, this doesn't sound like a timescaledb problem, so closing this out.

Thanks for the report though, that is helpful to know. We'll be looking into distributing Debian binaries in the near future, so it's good to know of potential pitfalls. Appreciate the report!

Yep, I hope this will be a good google result if someone has a similar problem. Thank you for taking the time to look at this, and for all your work on this project!

In file included from /home/ecarroll/code/timescaledb/src/extension.c:24:0:
/home/ecarroll/code/timescaledb/build/src/version.h:12:0: warning: "PG_VERSION" redefined
 #define PG_VERSION "10.5"

In file included from /usr/include/postgresql/10/server/c.h:53:0,
                 from /usr/include/postgresql/10/server/postgres.h:47,
                 from /home/ecarroll/code/timescaledb/src/extension.c:1:
/usr/include/postgresql/10/server/pg_config.h:770:0: note: this is the location of the previous definition
 #define PG_VERSION "10.5 (Ubuntu 10.5-0ubuntu0.18.04)"

My pg_config.h has this,

/* PostgreSQL version as a string */
#define PG_VERSION "10.5 (Ubuntu 10.5-0ubuntu0.18.04)"

I think what you want is PACKAGE_VERSION, or PG_VERSION_NUMBER from pg_config.h and then you can just delete your create of PG_VERSION (which is the conflicting macro)

#define PACKAGE_VERSION "10.5"
#define PG_VERSION_NUM 100006

I guess if you wanted you could defined TS_PG_VERSION to be the PACKAGE_VERSION from pg_config.h for clarity.

Using either PACKAGE_VERSION or PG_VERSION_NUM will save you from having regex process them (which was the solution to #424 ). Though I'm not sure how this would work on the 9.x series where you could theoretically make something specific for one patch of PostgreSQL (which shouldn't make a difference anyway because it's going to be ABI-compat with other major/minor versions even in the 9.x series).

Thank you so much!

Was this page helpful?
0 / 5 - 0 ratings