What generates pg_config.h?

2018-01-05 Thread Travis Allison
Hi,

I have postgres 9.5 and 9.6 installed.  pg_config points to 9.6.
I am trying to compile a postgresql plugin (Timescaledb).  I am getting an
error:
---
/usr/include/postgresql/pg_config.h:733:0: warning: "PACKAGE_VERSION"
redefined
 #define PACKAGE_VERSION "10.0"
 ^
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 /mnt/data/timescaledb/src/init.c:1:
/usr/include/postgresql/9.6/server/pg_config.h:740:0: note: this is the
location of the previous definition
 #define PACKAGE_VERSION "9.6.5"
-

The command pg_config gives the following:

---
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,-Bsymbolic-functions -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=-Wdate-time -D_FORTIFY_SOURCE=2'
CC = gcc
CPPFLAGS = -DFRONTEND -Wdate-time -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,-Bsymbolic-functions -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.5
-

So my question is: what is generating the
/usr/include/postgresql/pg_config.h file?  Why is it different than the
/usr/include/postgresql/9.6/server/pg_config.h file?

Thanks!

Travis


Re: What generates pg_config.h?

2018-01-05 Thread Adrian Klaver

On 01/05/2018 09:07 AM, Travis Allison wrote:

Hi,

I have postgres 9.5 and 9.6 installed.  pg_config points to 9.6.
I am trying to compile a postgresql plugin (Timescaledb).  I am getting 
an error:

---
/usr/include/postgresql/pg_config.h:733:0: warning: "PACKAGE_VERSION" 
redefined

  #define PACKAGE_VERSION "10.0"
  ^
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 /mnt/data/timescaledb/src/init.c:1:
/usr/include/postgresql/9.6/server/pg_config.h:740:0: note: this is the 
location of the previous definition

  #define PACKAGE_VERSION "9.6.5"
-

The command pg_config gives the following:

---
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,-Bsymbolic-functions -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=-Wdate-time -D_FORTIFY_SOURCE=2'

CC = gcc
CPPFLAGS = -DFRONTEND -Wdate-time -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,-Bsymbolic-functions -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.5
-

So my question is: what is generating the 
/usr/include/postgresql/pg_config.h file?  Why is it different than the 
/usr/include/postgresql/9.6/server/pg_config.h file?


I am guessing you have some part of Postgres 10 installed. During the 
build the extension is getting to /usr/include/postgresql/pg_config.h 
before it gets to /usr/include/postgresql/9.6/server/pg_config.h.  Crank 
up your package manager and see what your distro has installed? Along 
that line knowing what distro and version you are using as well as how 
you installed Postgres 9.5 and 9.6 would be helpful.




Thanks!

Travis



--
Adrian Klaver
adrian.kla...@aklaver.com



Postgres HA

2018-01-05 Thread Azimuddin Mohammed
Hello,
I am little confused with how HA works in postgres. Reading the article
which state as below "*If the primary server fails and the standby server
becomes the new primary, and then the old primary restarts, you must have a
mechanism for informing the old primary that it is no longer the primary.
This is sometimes known as STONITH (Shoot The Other Node In The Head),
which is necessary to avoid situations where both systems think they are
the primary, which will lead to confusion and ultimately data loss.*

*Many failover systems use just two systems, the primary and the standby,
connected by some kind of heartbeat mechanism to continually verify the
connectivity between the two and the viability of the primary. It is also
possible to use a third system (called a witness server) to prevent some
cases of inappropriate failover, but the additional complexity might not be
worthwhile unless it is set up with sufficient care and rigorous testing.*
*PostgreSQL does not provide the system software required to identify a
failure on the primary and notify the standby database server. Many such
tools exist and are well integrated with the operating system facilities
required for successful failover, such as IP address migration."*

Can someone explain how the HA failback will take place and what open
source tools we can use to make sure once the primary server which failed
over to slave will mark itself as slave.

Appreciate your response in advance.

-- 

Regards,
Azim



Virus-free.
www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


Re: Postgres HA

2018-01-05 Thread Scott Marlowe
On Fri, Jan 5, 2018 at 12:07 PM, Azimuddin Mohammed  wrote:
>
> Hello,
> I am little confused with how HA works in postgres. Reading the article which 
> state as below "If the primary server fails and the standby server becomes 
> the new primary, and then the old primary restarts, you must have a mechanism 
> for informing the old primary that it is no longer the primary. This is 
> sometimes known as STONITH (Shoot The Other Node In The Head), which is 
> necessary to avoid situations where both systems think they are the primary, 
> which will lead to confusion and ultimately data loss.
>
> Many failover systems use just two systems, the primary and the standby, 
> connected by some kind of heartbeat mechanism to continually verify the 
> connectivity between the two and the viability of the primary. It is also 
> possible to use a third system (called a witness server) to prevent some 
> cases of inappropriate failover, but the additional complexity might not be 
> worthwhile unless it is set up with sufficient care and rigorous testing.
>
> PostgreSQL does not provide the system software required to identify a 
> failure on the primary and notify the standby database server. Many such 
> tools exist and are well integrated with the operating system facilities 
> required for successful failover, such as IP address migration."
>
> Can someone explain how the HA failback will take place and what open source 
> tools we can use to make sure once the primary server which failed over to 
> slave will mark itself as slave.
>

There are LOTS of ways to implement HA.

Here's a book on the subject that's 537 pages long, and is only $4.99 right now:
https://www.packtpub.com/big-data-and-business-intelligence/postgresql-high-availability-cookbook-second-edition
I've been reading it a bit, seems to be a good resource.


-- 
To understand recursion, one must first understand recursion.



Re: Postgres HA

2018-01-05 Thread Rui DeSousa
There are many different solutions; but I would recommend and use a least a 
three node cluster using synchronous replication where one of the nodes is 
acting as the witness — at a minimum (actual have more replicas).  The witness 
node need not be a full Postgres instance; it can also be achieved by using 
pg_recievexlog as the witness instead.  This setup avoids a the split brain 
situation by making sure there is only one writable instance and that is the 
one that the witness is following.

I use CARP (Common Address Redundancy Protocol) to manage the HA IP address 
(very platform specific); when the address flips over to a replica it 
automatically promotes the replica and witness follows the HA address thus 
signing off on the self promotion.

The old primary then needs to be reconfigured as a replia which can be done 
using pg_rewind or other numerous other solutions; i.e. snapshots, backup, etc.
 
I have not personally used this solution; but you could look at 2ndQuadrant 
repmgr product if you’re looking a packaged solution.

https://www.2ndquadrant.com/en/resources/repmgr/installation-instructions/





Re: What generates pg_config.h?

2018-01-05 Thread Travis Allison
Distro and version:  Ubuntu 16.04 LTS.

If memory serves, I installed 9.5 using synaptic and 9.6 using apt-get,
where I followed the instructions from this site:
https://www.postgresql.org/download/linux/ubuntu/

I also have an anaconda installation of postgresql, but that is a version
less than 9.6.

Here are the results for postgresql using dpkg-query -l

ii  postgresql 9.5+173  all
 object-relational SQL database (supported version)
ii  postgresql-9.5 9.5.3-0ubuntu0.16.04 amd64
 object-relational SQL database, version 9.5 server
ii  postgresql-9.6 9.6.5-1.pgdg16.04+2  amd64
 object-relational SQL database, version 9.6 server
ii  postgresql-client-9.5  9.5.3-0ubuntu0.16.04 amd64
 front-end programs for PostgreSQL 9.5
ii  postgresql-client-9.6  9.6.5-1.pgdg16.04+2  amd64
 front-end programs for PostgreSQL 9.6
ii  postgresql-client-common   173  all
 manager for multiple PostgreSQL client versions
ii  postgresql-common  173  all
 PostgreSQL database-cluster manager
ii  postgresql-contrib-9.5 9.5.3-0ubuntu0.16.04 amd64
 additional facilities for PostgreSQL
ii  postgresql-contrib-9.6 9.6.5-1.pgdg16.04+2  amd64
 additional facilities for PostgreSQL
ii  postgresql-server-dev-9.5  9.5.3-0ubuntu0.16.04 amd64
 development files for PostgreSQL 9.5 server-side
programming
ii  postgresql-server-dev-9.6  9.6.5-1.pgdg16.04+2  amd64
 development files for PostgreSQL 9.6 server-side
programming


On Fri, Jan 5, 2018 at 10:24 AM, Adrian Klaver 
wrote:

> On 01/05/2018 09:07 AM, Travis Allison wrote:
>
>> Hi,
>>
>> I have postgres 9.5 and 9.6 installed.  pg_config points to 9.6.
>> I am trying to compile a postgresql plugin (Timescaledb).  I am getting
>> an error:
>> ---
>> /usr/include/postgresql/pg_config.h:733:0: warning: "PACKAGE_VERSION"
>> redefined
>>   #define PACKAGE_VERSION "10.0"
>>   ^
>> 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 /mnt/data/timescaledb/src/init.c:1:
>> /usr/include/postgresql/9.6/server/pg_config.h:740:0: note: this is the
>> location of the previous definition
>>   #define PACKAGE_VERSION "9.6.5"
>> -
>>
>> The command pg_config gives the following:
>>
>> ---
>> 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 <
>> http://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,-Bsymbolic-functions -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=-Wdate-time -D_FORTIFY_SOURCE=2'
>> CC = gcc
>> CPPFLAGS = -DFRONTEND -Wdate-time -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 -fex

Re: What generates pg_config.h?

2018-01-05 Thread Tom Lane
Travis Allison  writes:
> Distro and version:  Ubuntu 16.04 LTS.
> If memory serves, I installed 9.5 using synaptic and 9.6 using apt-get,
> where I followed the instructions from this site:
> https://www.postgresql.org/download/linux/ubuntu/

> I also have an anaconda installation of postgresql, but that is a version
> less than 9.6.

Well, this bit:

>>> /usr/include/postgresql/pg_config.h:733:0: warning: "PACKAGE_VERSION" 
>>> redefined
>>> #define PACKAGE_VERSION "10.0"

is proof positive that you've got at least some pieces of a v10
installation as well.  The location of the file (i.e., not under a
version-named subdirectory, like the others) suggests that that
installation was not aware of the conventions Ubuntu's packagers
like to use to separate different PG versions from each other.
And the lack of any relevant entry in the dpkg output suggests it didn't
come from any of your normal packages, either.  I'm wondering about an
ill-advised manual installation from raw PG source code, for instance.

Did you check whether this file is associated with any dpkg-installed
package?  (Not being an Ubuntu user, I don't know how to do that,
but I'm sure they have an equivalent of "rpm -qf".)

regards, tom lane



Re: What generates pg_config.h?

2018-01-05 Thread Adrian Klaver

On 01/05/2018 11:57 AM, Travis Allison wrote:

Distro and version:  Ubuntu 16.04 LTS.

If memory serves, I installed 9.5 using synaptic and 9.6 using apt-get, 
where I followed the instructions from this site: 
https://www.postgresql.org/download/linux/ubuntu/


I also have an anaconda installation of postgresql, but that is a 
version less than 9.6.


Here are the results for postgresql using dpkg-query -l


Well somehow a Postgres 10 version of pg_config.h got installed.
Is there an instance of Postgres 10 running?



ii  postgresql                             9.5+173                  all 
                      object-relational SQL database (supported version)
ii  postgresql-9.5                         9.5.3-0ubuntu0.16.04 
amd64                    object-relational SQL database, version 9.5 server
ii  postgresql-9.6                         9.6.5-1.pgdg16.04+2 
  amd64                    object-relational SQL database, version 9.6 
server
ii  postgresql-client-9.5                  9.5.3-0ubuntu0.16.04 
amd64                    front-end programs for PostgreSQL 9.5
ii  postgresql-client-9.6                  9.6.5-1.pgdg16.04+2 
  amd64                    front-end programs for PostgreSQL 9.6
ii  postgresql-client-common               173                      all 
                      manager for multiple PostgreSQL client versions
ii  postgresql-common                      173                      all 
                      PostgreSQL database-cluster manager
ii  postgresql-contrib-9.5                 9.5.3-0ubuntu0.16.04 
amd64                    additional facilities for PostgreSQL
ii  postgresql-contrib-9.6                 9.6.5-1.pgdg16.04+2 
  amd64                    additional facilities for PostgreSQL
ii  postgresql-server-dev-9.5              9.5.3-0ubuntu0.16.04 
amd64                    development files for PostgreSQL 9.5 
server-side programming
ii  postgresql-server-dev-9.6              9.6.5-1.pgdg16.04+2 
  amd64                    development files for PostgreSQL 9.6 
server-side programming







--
Adrian Klaver
adrian.kla...@aklaver.com



Re: What generates pg_config.h?

2018-01-05 Thread rob stone
Hello,

On Fri, 2018-01-05 at 12:19 -0800, Adrian Klaver wrote:
> On 01/05/2018 11:57 AM, Travis Allison wrote:
> > Distro and version:  Ubuntu 16.04 LTS.
> > 
> > If memory serves, I installed 9.5 using synaptic and 9.6 using apt-
> > get, 
> > where I followed the instructions from this site: 
> > https://www.postgresql.org/download/linux/ubuntu/
> > 
> > I also have an anaconda installation of postgresql, but that is a 
> > version less than 9.6.
> > 
> > Here are the results for postgresql using dpkg-query -l
> 
> Well somehow a Postgres 10 version of pg_config.h got installed.
> Is there an instance of Postgres 10 running?
> 
> > 
> > ii  postgresql 9.5+173
> >  all 
> >   object-relational SQL database (supported
> > version)
> > ii  postgresql-9.5 9.5.3-
> > 0ubuntu0.16.04 
> > amd64object-relational SQL database, version
> > 9.5 server
> > ii  postgresql-9.6 9.6.5-1.pgdg16.04+2 
> >   amd64object-relational SQL database, version
> > 9.6 
> > server
> > ii  postgresql-client-9.5  9.5.3-
> > 0ubuntu0.16.04 
> > amd64front-end programs for PostgreSQL 9.5
> > ii  postgresql-client-9.6  9.6.5-1.pgdg16.04+2 
> >   amd64front-end programs for PostgreSQL 9.6
> > ii  postgresql-client-common   173
> >  all 
> >   manager for multiple PostgreSQL client
> > versions
> > ii  postgresql-common  173
> >  all 
> >   PostgreSQL database-cluster manager
> > ii  postgresql-contrib-9.5 9.5.3-
> > 0ubuntu0.16.04 
> > amd64additional facilities for PostgreSQL
> > ii  postgresql-contrib-9.6 9.6.5-1.pgdg16.04+2 
> >   amd64additional facilities for PostgreSQL
> > ii  postgresql-server-dev-9.5  9.5.3-
> > 0ubuntu0.16.04 
> > amd64development files for PostgreSQL 9.5 
> > server-side programming
> > ii  postgresql-server-dev-9.6  9.6.5-1.pgdg16.04+2 
> >   amd64development files for PostgreSQL 9.6 
> > server-side programming
> > 
> > 
> 
> 
> 


Shouldn't the OP check the libpq-dev libraries as well?

Not an expert. My two cents.
Rob



Re: What generates pg_config.h?

2018-01-05 Thread Travis Allison
No instance of Postgres 10 running. I took Tom's suggestion: I ran dpkg -S
/usr/include/postgresql/pg_config.h
Result: libpq-dev: /usr/include/postgresql/pg_config.h

Here is the result from dpkg-query -l | grep libpq

ii  libpq-dev 10.0-1.pgdg16.04+1
   amd64header files for libpq5
(PostgreSQL library)
ii  libpq5:amd64  10.0-1.pgdg16.04+1
   amd64PostgreSQL C client library

So thanks to all of your help, I've identified the culprit.

Any suggestions on what to do next?



On Fri, Jan 5, 2018 at 12:19 PM, Adrian Klaver 
wrote:

> On 01/05/2018 11:57 AM, Travis Allison wrote:
>
>> Distro and version:  Ubuntu 16.04 LTS.
>>
>> If memory serves, I installed 9.5 using synaptic and 9.6 using apt-get,
>> where I followed the instructions from this site:
>> https://www.postgresql.org/download/linux/ubuntu/
>>
>> I also have an anaconda installation of postgresql, but that is a version
>> less than 9.6.
>>
>> Here are the results for postgresql using dpkg-query -l
>>
>
> Well somehow a Postgres 10 version of pg_config.h got installed.
> Is there an instance of Postgres 10 running?
>
>
>
>> ii  postgresql 9.5+173  all
>>  object-relational SQL database (supported version)
>> ii  postgresql-9.5 9.5.3-0ubuntu0.16.04 amd64
>>object-relational SQL database, version 9.5 server
>> ii  postgresql-9.6 9.6.5-1.pgdg16.04+2
>>  amd64object-relational SQL database, version 9.6 server
>> ii  postgresql-client-9.5  9.5.3-0ubuntu0.16.04 amd64
>>front-end programs for PostgreSQL 9.5
>> ii  postgresql-client-9.6  9.6.5-1.pgdg16.04+2
>>  amd64front-end programs for PostgreSQL 9.6
>> ii  postgresql-client-common   173  all
>>  manager for multiple PostgreSQL client versions
>> ii  postgresql-common  173  all
>>  PostgreSQL database-cluster manager
>> ii  postgresql-contrib-9.5 9.5.3-0ubuntu0.16.04 amd64
>>additional facilities for PostgreSQL
>> ii  postgresql-contrib-9.6 9.6.5-1.pgdg16.04+2
>>  amd64additional facilities for PostgreSQL
>> ii  postgresql-server-dev-9.5  9.5.3-0ubuntu0.16.04 amd64
>>development files for PostgreSQL 9.5 server-side
>> programming
>> ii  postgresql-server-dev-9.6  9.6.5-1.pgdg16.04+2
>>  amd64development files for PostgreSQL 9.6 server-side
>> programming
>>
>>
>>
>
>
> --
> Adrian Klaver
> adrian.kla...@aklaver.com
>


Re: Postgres HA

2018-01-05 Thread Jehan-Guillaume (ioguix) de Rorthais
On Fri, 5 Jan 2018 13:07:10 -0600
Azimuddin Mohammed  wrote:

> Hello,
> I am little confused with how HA works in postgres. Reading the article
> which state as below "*If the primary server fails and the standby server
> becomes the new primary, and then the old primary restarts, you must have a
> mechanism for informing the old primary that it is no longer the primary.
> This is sometimes known as STONITH (Shoot The Other Node In The Head),
> which is necessary to avoid situations where both systems think they are
> the primary, which will lead to confusion and ultimately data loss.*
> 
> *Many failover systems use just two systems, the primary and the standby,
> connected by some kind of heartbeat mechanism to continually verify the
> connectivity between the two and the viability of the primary. It is also
> possible to use a third system (called a witness server) to prevent some
> cases of inappropriate failover, but the additional complexity might not be
> worthwhile unless it is set up with sufficient care and rigorous testing.*
> *PostgreSQL does not provide the system software required to identify a
> failure on the primary and notify the standby database server. Many such
> tools exist and are well integrated with the operating system facilities
> required for successful failover, such as IP address migration."*
> 
> Can someone explain how the HA failback will take place

The failback need either to rebuild the old master as a standby (rsync,
pg_basebackup, restore PITR, ...) or to use pg_rewind to rewind the old master
to a point where it can catch up with the new master.

Some tools tries to automate failback using pg_rewind (patroni, repmgr), but I
have no experience with them.

> and what open source tools we can use to make sure once the primary server
> which failed over to slave will mark itself as slave.

There's a lot of open source tools to build some HA around PgSQL: Repmgr,
Patroni (based on etcd or zookeeper), PAF (based on Pacemaker), etc. You will
have to spend a lot of time to make extensive tests, understand them, pick one
and document your cluster.

Regards,



Re: What generates pg_config.h?

2018-01-05 Thread Alvaro Herrera
Travis Allison wrote:
> No instance of Postgres 10 running. I took Tom's suggestion: I ran dpkg -S
> /usr/include/postgresql/pg_config.h
> Result: libpq-dev: /usr/include/postgresql/pg_config.h
> 
> Here is the result from dpkg-query -l | grep libpq
> 
> ii  libpq-dev 10.0-1.pgdg16.04+1
>amd64header files for libpq5
> (PostgreSQL library)
> ii  libpq5:amd64  10.0-1.pgdg16.04+1
>amd64PostgreSQL C client library
> 
> So thanks to all of your help, I've identified the culprit.
> 
> Any suggestions on what to do next?

I wonder if there is a mistake in the use of INCLUDEDIR vs.
INCLUDEDIR-SERVER for -I.  Maybe both are being used, and looks like
only the latter should be.  It seems odd that there are two pg_config.h
files getting included ...

but I do wonder why is there a pg_config.h in libpq-dev.

-- 
Álvaro Herrerahttps://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



Re: What generates pg_config.h?

2018-01-05 Thread Tom Lane
Alvaro Herrera  writes:
> Travis Allison wrote:
>> No instance of Postgres 10 running. I took Tom's suggestion: I ran dpkg -S
>> /usr/include/postgresql/pg_config.h
>> Result: libpq-dev: /usr/include/postgresql/pg_config.h

Ah, thanks for clearing that up.

>> Any suggestions on what to do next?

> I wonder if there is a mistake in the use of INCLUDEDIR vs.
> INCLUDEDIR-SERVER for -I.  Maybe both are being used, and looks like
> only the latter should be.  It seems odd that there are two pg_config.h
> files getting included ...

Yeah ...

> but I do wonder why is there a pg_config.h in libpq-dev.

Now I seem to recall some discussion with a packager who felt that
providing just the latest-and-greatest libpq was sufficient for
clients, and only server-side code needed to depend on the server
version.  So I'm betting that the intention on the Ubuntu packager's
end is that you use a -I for /usr/include/postgresql when building
client code, while if you want to build a server extension, you
point at the appropriate version subdirectory.  Meanwhile, the
extension Travis is trying to build is unfamiliar with that idea
and is throwing in a bunch of -I switches willy-nilly.

In short, yeah, try removing the -I that's pointing at the upper
directory.

regards, tom lane



Re: What generates pg_config.h?

2018-01-05 Thread Travis Allison
Tom, where's the -l switch exactly?  What command is it attached to? (I'm
not sure what to look for.)

Thanks,

Travis

On Fri, Jan 5, 2018 at 2:56 PM, Tom Lane  wrote:

> Alvaro Herrera  writes:
> > Travis Allison wrote:
> >> No instance of Postgres 10 running. I took Tom's suggestion: I ran dpkg
> -S
> >> /usr/include/postgresql/pg_config.h
> >> Result: libpq-dev: /usr/include/postgresql/pg_config.h
>
> Ah, thanks for clearing that up.
>
> >> Any suggestions on what to do next?
>
> > I wonder if there is a mistake in the use of INCLUDEDIR vs.
> > INCLUDEDIR-SERVER for -I.  Maybe both are being used, and looks like
> > only the latter should be.  It seems odd that there are two pg_config.h
> > files getting included ...
>
> Yeah ...
>
> > but I do wonder why is there a pg_config.h in libpq-dev.
>
> Now I seem to recall some discussion with a packager who felt that
> providing just the latest-and-greatest libpq was sufficient for
> clients, and only server-side code needed to depend on the server
> version.  So I'm betting that the intention on the Ubuntu packager's
> end is that you use a -I for /usr/include/postgresql when building
> client code, while if you want to build a server extension, you
> point at the appropriate version subdirectory.  Meanwhile, the
> extension Travis is trying to build is unfamiliar with that idea
> and is throwing in a bunch of -I switches willy-nilly.
>
> In short, yeah, try removing the -I that's pointing at the upper
> directory.
>
> regards, tom lane
>


Re: What generates pg_config.h?

2018-01-05 Thread Tom Lane
Travis Allison  writes:
> Tom, where's the -l switch exactly?  What command is it attached to? (I'm
> not sure what to look for.)

Look into the extension's Makefile for something roughly along the lines
of

CPPFLAGS = -I/usr/include/postgresql

Very likely there's some amount of macro-ization involved, so it might
look more like

INCLUDEDIR = /usr/include/postgresql
...
CPPFLAGS = -I$(INCLUDEDIR)

Furthermore, given our current theory, there's going to be more than
one -I switch on that line, and you want to get rid of just one.

regards, tom lane



Re: What generates pg_config.h?

2018-01-05 Thread Adrian Klaver

On 01/05/2018 03:29 PM, Tom Lane wrote:

Travis Allison  writes:

Tom, where's the -l switch exactly?  What command is it attached to? (I'm
not sure what to look for.)


Look into the extension's Makefile for something roughly along the lines
of


Assuming the OP is talking about this:

https://github.com/timescale/timescaledb

I believe there is an intervening step:

# Bootstrap the build system
./bootstrap

If I am following correctly the -I are in:

CMakeLists.txt

# Get PostgreSQL configuration from pg_config
execute_process(
  COMMAND ${PG_CONFIG} --includedir
  OUTPUT_VARIABLE PG_INCLUDEDIR
  OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
  COMMAND ${PG_CONFIG} --includedir-server
  OUTPUT_VARIABLE PG_INCLUDEDIR_SERVER
OUTPUT_STRIP_TRAILING_WHITESPACE)


There does seem to be an apt install:

http://docs.timescale.com/v0.8/getting-started/installation/linux/installation-apt

with the following caveats:
"
Note: PostgreSQL 9.6 is required for TimescaleDB on Ubuntu distros. 
Releases with PostgreSQL 10 are coming soon

Prerequisites

Ubuntu 16.04 or later

Build & Install

WARNING:If you have another PostgreSQL installation not via apt, 
this will likely cause problems. If you wish to maintain your current 
version of PostgreSQL outside of apt, we recommend installing from 
source. Otherwise please be sure to remove non-apt installations before 
using this method.

"



CPPFLAGS = -I/usr/include/postgresql

Very likely there's some amount of macro-ization involved, so it might
look more like

INCLUDEDIR = /usr/include/postgresql
...
CPPFLAGS = -I$(INCLUDEDIR)

Furthermore, given our current theory, there's going to be more than
one -I switch on that line, and you want to get rid of just one.

regards, tom lane




--
Adrian Klaver
adrian.kla...@aklaver.com



Re: Postgres HA

2018-01-05 Thread John Scalia
What he said, and you also may want to look at pgpool-II. I’ve had fairly good 
luck with that and Tatsuo (the author) hangs out here occasionally too.
—
Jay

Sent from my iPad

> On Jan 5, 2018, at 4:00 PM, Jehan-Guillaume (ioguix) de Rorthais 
>  wrote:
> 
> On Fri, 5 Jan 2018 13:07:10 -0600
> Azimuddin Mohammed  wrote:
> 
>> Hello,
>> I am little confused with how HA works in postgres. Reading the article
>> which state as below "*If the primary server fails and the standby server
>> becomes the new primary, and then the old primary restarts, you must have a
>> mechanism for informing the old primary that it is no longer the primary.
>> This is sometimes known as STONITH (Shoot The Other Node In The Head),
>> which is necessary to avoid situations where both systems think they are
>> the primary, which will lead to confusion and ultimately data loss.*
>> 
>> *Many failover systems use just two systems, the primary and the standby,
>> connected by some kind of heartbeat mechanism to continually verify the
>> connectivity between the two and the viability of the primary. It is also
>> possible to use a third system (called a witness server) to prevent some
>> cases of inappropriate failover, but the additional complexity might not be
>> worthwhile unless it is set up with sufficient care and rigorous testing.*
>> *PostgreSQL does not provide the system software required to identify a
>> failure on the primary and notify the standby database server. Many such
>> tools exist and are well integrated with the operating system facilities
>> required for successful failover, such as IP address migration."*
>> 
>> Can someone explain how the HA failback will take place
> 
> The failback need either to rebuild the old master as a standby (rsync,
> pg_basebackup, restore PITR, ...) or to use pg_rewind to rewind the old master
> to a point where it can catch up with the new master.
> 
> Some tools tries to automate failback using pg_rewind (patroni, repmgr), but I
> have no experience with them.
> 
>> and what open source tools we can use to make sure once the primary server
>> which failed over to slave will mark itself as slave.
> 
> There's a lot of open source tools to build some HA around PgSQL: Repmgr,
> Patroni (based on etcd or zookeeper), PAF (based on Pacemaker), etc. You will
> have to spend a lot of time to make extensive tests, understand them, pick one
> and document your cluster.
> 
> Regards,
> 



Re: Postgres HA

2018-01-05 Thread Tatsuo Ishii
Hi,

Yes, definitely I am hanging out here.

If you have more specific questions to Pgpool-II, you are encouraged
to be subscribed to the Pgpool-II mailing list.
https://www.pgpool.net/mailman/listinfo/pgpool-general

Best regards,
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese:http://www.sraoss.co.jp

> What he said, and you also may want to look at pgpool-II. I’ve had fairly 
> good luck with that and Tatsuo (the author) hangs out here occasionally too.
> ―
> Jay
> 
> Sent from my iPad
> 
>> On Jan 5, 2018, at 4:00 PM, Jehan-Guillaume (ioguix) de Rorthais 
>>  wrote:
>> 
>> On Fri, 5 Jan 2018 13:07:10 -0600
>> Azimuddin Mohammed  wrote:
>> 
>>> Hello,
>>> I am little confused with how HA works in postgres. Reading the article
>>> which state as below "*If the primary server fails and the standby server
>>> becomes the new primary, and then the old primary restarts, you must have a
>>> mechanism for informing the old primary that it is no longer the primary.
>>> This is sometimes known as STONITH (Shoot The Other Node In The Head),
>>> which is necessary to avoid situations where both systems think they are
>>> the primary, which will lead to confusion and ultimately data loss.*
>>> 
>>> *Many failover systems use just two systems, the primary and the standby,
>>> connected by some kind of heartbeat mechanism to continually verify the
>>> connectivity between the two and the viability of the primary. It is also
>>> possible to use a third system (called a witness server) to prevent some
>>> cases of inappropriate failover, but the additional complexity might not be
>>> worthwhile unless it is set up with sufficient care and rigorous testing.*
>>> *PostgreSQL does not provide the system software required to identify a
>>> failure on the primary and notify the standby database server. Many such
>>> tools exist and are well integrated with the operating system facilities
>>> required for successful failover, such as IP address migration."*
>>> 
>>> Can someone explain how the HA failback will take place
>> 
>> The failback need either to rebuild the old master as a standby (rsync,
>> pg_basebackup, restore PITR, ...) or to use pg_rewind to rewind the old 
>> master
>> to a point where it can catch up with the new master.
>> 
>> Some tools tries to automate failback using pg_rewind (patroni, repmgr), but 
>> I
>> have no experience with them.
>> 
>>> and what open source tools we can use to make sure once the primary server
>>> which failed over to slave will mark itself as slave.
>> 
>> There's a lot of open source tools to build some HA around PgSQL: Repmgr,
>> Patroni (based on etcd or zookeeper), PAF (based on Pacemaker), etc. You will
>> have to spend a lot of time to make extensive tests, understand them, pick 
>> one
>> and document your cluster.
>> 
>> Regards,
>> 
> 



Re: Postgres HA

2018-01-05 Thread Azimuddin Mohammed
Thank you..I have subscribed to the list..


On Jan 5, 2018 8:09 PM, "Tatsuo Ishii"  wrote:

> Hi,
>
> Yes, definitely I am hanging out here.
>
> If you have more specific questions to Pgpool-II, you are encouraged
> to be subscribed to the Pgpool-II mailing list.
> https://www.pgpool.net/mailman/listinfo/pgpool-general
>
> Best regards,
> --
> Tatsuo Ishii
> SRA OSS, Inc. Japan
> English: http://www.sraoss.co.jp/index_en.php
> Japanese:http://www.sraoss.co.jp
>
> > What he said, and you also may want to look at pgpool-II. I’ve had
> fairly good luck with that and Tatsuo (the author) hangs out here
> occasionally too.
> > ―
> > Jay
> >
> > Sent from my iPad
> >
> >> On Jan 5, 2018, at 4:00 PM, Jehan-Guillaume (ioguix) de Rorthais <
> iog...@free.fr> wrote:
> >>
> >> On Fri, 5 Jan 2018 13:07:10 -0600
> >> Azimuddin Mohammed  wrote:
> >>
> >>> Hello,
> >>> I am little confused with how HA works in postgres. Reading the article
> >>> which state as below "*If the primary server fails and the standby
> server
> >>> becomes the new primary, and then the old primary restarts, you must
> have a
> >>> mechanism for informing the old primary that it is no longer the
> primary.
> >>> This is sometimes known as STONITH (Shoot The Other Node In The Head),
> >>> which is necessary to avoid situations where both systems think they
> are
> >>> the primary, which will lead to confusion and ultimately data loss.*
> >>>
> >>> *Many failover systems use just two systems, the primary and the
> standby,
> >>> connected by some kind of heartbeat mechanism to continually verify the
> >>> connectivity between the two and the viability of the primary. It is
> also
> >>> possible to use a third system (called a witness server) to prevent
> some
> >>> cases of inappropriate failover, but the additional complexity might
> not be
> >>> worthwhile unless it is set up with sufficient care and rigorous
> testing.*
> >>> *PostgreSQL does not provide the system software required to identify a
> >>> failure on the primary and notify the standby database server. Many
> such
> >>> tools exist and are well integrated with the operating system
> facilities
> >>> required for successful failover, such as IP address migration."*
> >>>
> >>> Can someone explain how the HA failback will take place
> >>
> >> The failback need either to rebuild the old master as a standby (rsync,
> >> pg_basebackup, restore PITR, ...) or to use pg_rewind to rewind the old
> master
> >> to a point where it can catch up with the new master.
> >>
> >> Some tools tries to automate failback using pg_rewind (patroni,
> repmgr), but I
> >> have no experience with them.
> >>
> >>> and what open source tools we can use to make sure once the primary
> server
> >>> which failed over to slave will mark itself as slave.
> >>
> >> There's a lot of open source tools to build some HA around PgSQL:
> Repmgr,
> >> Patroni (based on etcd or zookeeper), PAF (based on Pacemaker), etc.
> You will
> >> have to spend a lot of time to make extensive tests, understand them,
> pick one
> >> and document your cluster.
> >>
> >> Regards,
> >>
> >
>


Re: What generates pg_config.h?

2018-01-05 Thread Travis Allison
I suppose an easy workaround is to copy my version 9.6 pg_config.h into my
user/include/postgresql directory and replace the one installed by
libpq-dev.

Can you think of any detrimental side-effects from doing that?

Travis

On Fri, Jan 5, 2018 at 3:40 PM, Adrian Klaver 
wrote:

> On 01/05/2018 03:29 PM, Tom Lane wrote:
>
>> Travis Allison  writes:
>>
>>> Tom, where's the -l switch exactly?  What command is it attached to? (I'm
>>> not sure what to look for.)
>>>
>>
>> Look into the extension's Makefile for something roughly along the lines
>> of
>>
>
> Assuming the OP is talking about this:
>
> https://github.com/timescale/timescaledb
>
> I believe there is an intervening step:
>
> # Bootstrap the build system
> ./bootstrap
>
> If I am following correctly the -I are in:
>
> CMakeLists.txt
>
> # Get PostgreSQL configuration from pg_config
> execute_process(
>   COMMAND ${PG_CONFIG} --includedir
>   OUTPUT_VARIABLE PG_INCLUDEDIR
>   OUTPUT_STRIP_TRAILING_WHITESPACE)
> execute_process(
>   COMMAND ${PG_CONFIG} --includedir-server
>   OUTPUT_VARIABLE PG_INCLUDEDIR_SERVER
> OUTPUT_STRIP_TRAILING_WHITESPACE)
>
>
> There does seem to be an apt install:
>
> http://docs.timescale.com/v0.8/getting-started/installation/
> linux/installation-apt
>
> with the following caveats:
> "
> Note: PostgreSQL 9.6 is required for TimescaleDB on Ubuntu distros.
> Releases with PostgreSQL 10 are coming soon
> Prerequisites
>
> Ubuntu 16.04 or later
>
> Build & Install
>
> WARNING:If you have another PostgreSQL installation not via apt, this
> will likely cause problems. If you wish to maintain your current version of
> PostgreSQL outside of apt, we recommend installing from source. Otherwise
> please be sure to remove non-apt installations before using this method.
>
> "
>
>
>> CPPFLAGS = -I/usr/include/postgresql
>>
>> Very likely there's some amount of macro-ization involved, so it might
>> look more like
>>
>> INCLUDEDIR = /usr/include/postgresql
>> ...
>> CPPFLAGS = -I$(INCLUDEDIR)
>>
>> Furthermore, given our current theory, there's going to be more than
>> one -I switch on that line, and you want to get rid of just one.
>>
>> regards, tom lane
>>
>>
>
> --
> Adrian Klaver
> adrian.kla...@aklaver.com
>


Re: What generates pg_config.h?

2018-01-05 Thread Tom Lane
Travis Allison  writes:
> I suppose an easy workaround is to copy my version 9.6 pg_config.h into my
> user/include/postgresql directory and replace the one installed by
> libpq-dev.

> Can you think of any detrimental side-effects from doing that?

I would not recommend that: it's likely to break code that's expecting
the Ubuntu-standard layout.  I think your best course is to adapt the
particular package you're having trouble with to work with that layout.
Maybe contact its author for help?

regards, tom lane



Re: What generates pg_config.h?

2018-01-05 Thread Travis Allison
Tom, I guess I don't understand the point of having a different pg_config.h
in my user/include/postgresql directory than the postgresql server that I
am running.  You mentioned building client code that would reference the
pg_config.h in user/include/postgresql.  A couple of questions:

What type of client code are you referring to?
What is the point of having a pg_config.h for a server that I am not even
running?

Travis





On Fri, Jan 5, 2018 at 8:05 PM, Tom Lane  wrote:

> Travis Allison  writes:
> > I suppose an easy workaround is to copy my version 9.6 pg_config.h into
> my
> > user/include/postgresql directory and replace the one installed by
> > libpq-dev.
>
> > Can you think of any detrimental side-effects from doing that?
>
> I would not recommend that: it's likely to break code that's expecting
> the Ubuntu-standard layout.  I think your best course is to adapt the
> particular package you're having trouble with to work with that layout.
> Maybe contact its author for help?
>
> regards, tom lane
>