GithubHelp home page GithubHelp logo

reorg / pg_repack Goto Github PK

View Code? Open in Web Editor NEW
1.8K 55.0 168.0 1.14 MB

Reorganize tables in PostgreSQL databases with minimal locks

License: BSD 3-Clause "New" or "Revised" License

Makefile 2.84% C 92.74% PLpgSQL 4.19% Shell 0.22%

pg_repack's Introduction

pg_repack -- Reorganize tables in PostgreSQL databases with minimal locks

Linux build status

pg_repack is a PostgreSQL extension which lets you remove bloat from tables and indexes, and optionally restore the physical order of clustered indexes. Unlike CLUSTER and VACUUM FULL it works online, without holding an exclusive lock on the processed tables during processing. pg_repack is efficient to boot, with performance comparable to using CLUSTER directly.

Please check the documentation (in the doc directory or online) for installation and usage instructions.

What about pg_reorg?

pg_repack is a fork of the pg_reorg project, which has proven hugely successful. Unfortunately new feature development on pg_reorg has slowed or stopped since late 2011.

pg_repack was initially released as a drop-in replacement for pg_reorg, addressing some of the shortcomings of the last pg_reorg version (such as support for PostgreSQL 9.2 and EXTENSION packaging) and known bugs.

pg_repack 1.2 introduces further new features (parallel index builds, ability to rebuild only indexes) and bugfixes. In some cases its behaviour may be different from the 1.1.x release so it shouldn't be considered a drop-in replacement: you are advised to check the documentation before upgrading from previous versions.

pg_repack's People

Contributors

adunstan avatar amitlan avatar andreasscherbaum avatar bearpreis avatar bwtakacy avatar cpaelzer avatar df7cb avatar drakkan avatar dvarrazzo avatar einkrebs avatar fabriziomello avatar funbringer avatar itgacky avatar kotik-adjust avatar kotsachin avatar lincuiping avatar magat avatar masahikosawada avatar melkij avatar michaeldba avatar mooninsung avatar nathan-bossart avatar schmiddy avatar simi avatar snorkypie avatar sunhm89 avatar terrorobe avatar tometzky avatar za-arthur avatar zhuqx-fnst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pg_repack's Issues

Install fails on PostgreSQL 9.3 and Debian 7.7 Wheezy (/usr/bin/ld: cannot find -ledit)

Installed from PostgreSQL from this repo:
deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main

This is last lines of compilation:

/usr/bin/ld: cannot find -ledit
collect2: error: ld returned 1 exit status
make[1]: *** [pg_repack] Greška 1
make[1]: Izlazim iz direktorija `/tmp/tmphZCIbF/pg_repack-1.2.1/bin'
make: *** [all] Greška 2
ERROR: command returned 2: make PG_CONFIG=/usr/bin/pg_config all

There was a notice with tihs error that I need libcuda. I installed libcuda1 and libcudart4 but the problem still exists.

Data corruption in concurrent delete

Analysis and bugfix by Josh. Opening the issue for reference: Josh email is not available in ML archive. The bug has already been fixed and ready to be released in pg_repack 1.2.0.

OK, I found some time to revisit this bug. Here's a test script with
which I managed to reproduce the problem fairly consistently (see
comments for initial table setup, etc.) I was testing with pg_repack
master, with just a few sleep calls like so sprinkled in to encourage
races (extra_sleeps.diff debugging patch attached). To reproduce, just
start up that repack_bug.py script, let it run for a few seconds to
start populating rows, then kick off an extra_sleeps-patched pg_repack
of table "parent", and afterwards you should get some broken FKs.

AFAICT, the problem only occurs when the test script is using more
than one child process, i.e. concurrent transactions are queueing rows
into the repack log table. So where's the bug? It seems the sql_pop
query used in repack_apply() is to blame. It tries to bulk-delete the
rows it has already processed from the log table via a query like:

DELETE FROM repack.log_22520137 WHERE id <= $1

assuming that any "id" value less than the first "id" it started
processing in its current batch is safe to delete. But this assumption
may not hold if we have say:

T1: BEGIN
T1: DELETE FROM table_being_repacked WHERE ...
T1: ... hangs out for a while ...

T2: BEGIN
T2: INSERT INTO table_being_repacked ...
T2: COMMIT

... later ...

T1: COMMIT
/* repack_apply's sql_pop may run here */

In this example repack_apply() may delete T1's entry in the repack log
table without having actually carried out T1's DELETE on the repack
temp table. Attached is a patch to turn that bulk-delete into a delete
for every row we process out of the log table
(delete_individual_rows.diff). That'll be slower of course, but it
could be optimized into a bulk delete by keeping track of all the IDs
we have processed, and performing a single DELETE FROM repack.log_xyz
WHERE id IN (...).

At least, I hope this is the bug which I got bitten by back in
February. Other thoughts are welcome of course.

Cannot build pg_repack with Visual studio 2010 Express

Hi,

I cloned this repository and was trying to build the solution pg_repack.2010.sln
I am trying to build pg_repack on Visual studio 2010 Express for 64 bit windows.

Here is my error messages:

1>------ Build started: Project: bin.2010, Configuration: 9.0 x64 ------
2>------ Build started: Project: lib.2010, Configuration: 9.0 x64 ------
2> pgut-be.c
2>..\lib\pgut\pgut-be.c(11): fatal error C1083: Cannot open include file: 'postgres.h': No such file or directory
2> pgut-spi.c
2>..\lib\pgut\pgut-spi.c(10): fatal error C1083: Cannot open include file: 'postgres.h': No such file or directory
2> repack.c
2>..\lib\repack.c(9): fatal error C1083: Cannot open include file: 'postgres.h': No such file or directory
1> pgut-fe.c
1>c:\pg_repack\pg_repack\bin\pgut\pgut.h(13): fatal error C1083: Cannot open include file: 'c.h': No such file or directory
1> pgut.c
1>..\bin\pgut\pgut.c(10): fatal error C1083: Cannot open include file: 'postgres_fe.h': No such file or directory
1> pg_repack.c
1>c:\pg_repack\pg_repack\bin\pgut\pgut.h(13): fatal error C1083: Cannot open include file: 'c.h': No such file or directory

Can you guide to the solution

No self cleaning process in pg_repack on error.

As documentation says, pg_repack throws the following error if the given database object does not exist:

$ pg_repack -t tbl -o col3
INFO: repacking table "tbl"
ERROR: query failed: ERROR:  column "col3" does not exist LINE 1: ...CE pg_default AS SELECT co1,col2 FROM ONLY tbl ORDER BY col3
                                                                   ^
DETAIL: query was: CREATE TABLE repack.table_212909 WITH (oids=false) TABLESPACE pg_default AS SELECT co1,col2 FROM ONLY tbl ORDER BY col3 ````

There remains temporal objects created by pg_repack, like repack.log_* table or so on.

postgres=# \d repack.
repack.log_212909_id_seq  repack.primary_keys       repack.log_212909
repack.log_212909_pkey    repack.pk_212909          repack.tables

Immediately if user run pg_repack again with existing column name, it shows another error:

$ pg_repack -t tbl -o col2
INFO: repacking table "tbl"
WARNING: the table "tbl" already has a trigger called "z_repack_trigger"
...

Though the temporal objects can be removed by DROP EXTENSION, but it seems to be better to cleanup temporal objects by pg_repack itself. As it is usual that user can do typing mistake while specifying column name, there are many chances to occur this situation.

How we can improve:

We can write separate cleaning function which will call to repack_drop() for cleaning temporary objects, similar to repack_cleanup().
Pushing this cleaning function on stack using pgut_atexit_push() enables pg_repack to remove temporal objects before exiting.

Thought?

Avoid autovacuums of the target table

Another frustration we've experienced while running pg_repack in a busy production database is having autovacuum kick in for the table while in the middle of repacking -- not such an unlikely scenario for a busy table. This is a waste of precious I/O at best, and can also cause a nuisance for lock_exclusive() to cancel/terminate.

It would be nice if we could simply do an ALTER TABLE ... SET autovacuum_enabled=false on the target table while we're repacking. Restoring the original value in the case that pg_repack gets killed might take some thought, though.

pg_repack corrupts an unlogged table

I have no idea how it happend, but this is what I seen:

  1. try to pg_repack an unlogged table
  2. postgresql killed by linux oom-killer
  3. pg_repack try to reconnect, but failed because postmaster is recovering
  4. after recovery, pg_repack continue (?) and run repack.repack_drop
  5. my application is restarted.
  6. postmaster complain the index have zero page, suggest me to reindex
  7. reindex the table give duplicated rows and fails.

I guess unlogged tables should not be repacked in the first place, right?

$PG_CONFIG from the environement is overriden in the Makefile

This prevents cleanly installing for a different postgres version than the one pointed to by the default pg_config. As it happens, the Makefiles for the lib and the sql file do take the environement's PG_CONFIG into account.

Steps to reproduce:

  • Have multiple versions of pg installed
  • $ export PG_CONFIG=/path/to/nonstandard/pg_config
  • $ make && make DESTDIR=/some/where install
  • $ ls -R /some/where
  • Notice how the pg_repack binary is installed into the wrong pg folder (other installed files are fine)

Since the proper "PG_CONFIG ?= pg_config" is already present at the top of all makefiles, the fix that worked for me was to remove the line "PG_CONFIG = pg_config" at the bottom of regress/Makefile and bin/Makefile.

pg_repack causes PostgreSQL process crash with pg_statsinfo 3.0 on PostgreSQL 9.4.

We, pg_reorg team encountered this trouble and found pg_repack has the same one.
This is not a serious problem for users who do not use pg_statsinfo, but the root cause of this problem can be happened in using pg_repack and other PostgreSQL extensions together.
I feel that it is safe to do similar fix in pg_repack.

Here is a detail report.

Environment

・PostgreSQL 9.4
・pg_statsinfo 3.0.2
・pg_reorg 1.1.11 or pg_repack 1.3.1

How to reproduce

Start PostgreSQL with setting shared_preload_libraries = 'pg_statsinfo'.

$ psql -d postgres -c "CREATE TABLE test1 ( a int PRIMARY KEY);"
$ pg_reorg -d postgres -t test1 -o a
or
$ pg_repack -d postgres -t test1 -o a

Then, postgres backend process cranshes with segmentation fault.

Cause

The segmentation fault is happened in appendStringInfoVA_s() function defined in pg_statsinfo.
Though the function with the same name exists in pg_reorg/pg_repack and this does not cause problem, the postgres backend process choose the one in pg_statsinfo side and this is not compatible with PostgreSQL 9.4.

We found, if there are several function definitions with the same name in different shared libraries,
the postgres process uses the one defined in the shared library loaded first.

Fix

We decided that it is better not to export internal functions from reorg shared library in order to avoid symbol conflicts. This can be done by using linker option --version-script and we have found that libpq does this; use SHLIB_EXPORTS environment variable in Makefile and add text file where the functions to be exported are listed.
The below is the commit for pg_reorg.
bwtakacy/pg_reorg@5d9bbae

Reference

Regards,
Takashi Ohnishi

Unable to build on Amazon Linux (CentOS) - Missing lpgport/lpam

Hey,

I'm trying to build pg_repack on an Amazon Linux cluster running Postgres 9.2 but getting the following message about missing pgport/pam:

Both -devel and -contrib rpms are installed as well.

Any help would greatly be appreciated.

Armand

[ec2-user@ip-10-166-5-184 pg_repack-1.1.8]$ make
make[1]: Entering directory /home/ec2-user/src/pg_repack-1.1.8/bin' gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -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 pg_repack.o pgut/pgut.o pgut/pgut-fe.o -L/usr/lib64 -lpq -L/usr/lib64 -Wl,--as-needed -lpgport -lpam -lssl -lcrypto -lkrb5 -lcom_err -lgssapi_krb5 -lz -lreadline -lcrypt -ldl -lm -o pg_repack /usr/bin/ld: cannot find -lpgport /usr/bin/ld: cannot find -lpam collect2: ld returned 1 exit status make[1]: *** [pg_repack] Error 1 make[1]: Leaving directory/home/ec2-user/src/pg_repack-1.1.8/bin'
make: *** [all] Error 2

[ec2-user@ip-10-166-5-184 pg_repack-1.1.8]$ sudo yum list installed | grep postgres
Failed to set locale, defaulting to C
postgresql.noarch 9.2-1.19.amzn1 @amzn-main
postgresql-devel.noarch 9.2-1.19.amzn1 @amzn-updates
postgresql-server.noarch 9.2-1.19.amzn1 @amzn-main
postgresql-upgrade.noarch 9.2-1.19.amzn1 @amzn-main
postgresql9.x86_64 9.2.4-1.35.amzn1 @amzn-updates
postgresql9-contrib.x86_64 9.2.4-1.35.amzn1 @amzn-updates
postgresql9-devel.x86_64 9.2.4-1.35.amzn1 @amzn-updates
postgresql9-libs.x86_64 9.2.4-1.35.amzn1 @amzn-updates
postgresql9-server.x86_64 9.2.4-1.35.amzn1 @amzn-updates
postgresql9-upgrade.x86_64 9.2.4-1.35.amzn1 @amzn-updates

Create index with expression that uses table name

I have following index that uses expression:

CREATE INDEX my_table_idx
on shard0.my_table USING gin(shard0.my_func(my_table));

which pg_repack rewrites as

CREATE INDEX index_316298 ON repack.table_17593 USING gin (shard0.my_func(my_table.*))

which fails with

ERROR: query failed: ERROR:  missing FROM-clause entry for table "my_table"

segfault on 1.2.1

this is not a good bug report as i'm not able to reproduce it myself, can only describe the scenario:

the segfault happened on a partitioned table, when pg started a INSERT into a partition i had started pg_repack on a few seconds ago. according to syslog/kern.log the postgres backend segfaulted followed by pg_repack fractions of a second later. I'm not able to provide core dumps, they where not enabled on this (production) machine.
I use pg_repack quite frequently and never saw this happen, this machine is so far special that it is quite busy, lots of inserts, updates and deletes (its some sort of cache), so i suspect some kind of a race condition that caused the problem.

I'm aware that 1.2.1 is a bit outdated, meanwhile this has been upgraded to 1.3.2.

Versions:
OS: Debian wheezy 7.2 with a 3.16.0 kernel from wheezy backports
PG: 9.3.2 from apt.postgresql.org
REPACK: 1.2.1, compiled from source

just wanted to let you guys know, feel free to close it immediately as you most likely cant reproduce it either, and tnx for the good work

Avoid cancel and terminate backends

Hello,

as I can't afford to happen pg_cancel_backend() or pg_terminate_backend() on a production DB (which could come up if pg_repack is waiting for --wait-timeout for its lock on repacked table), is it completly safe (in not running cancel/terminate way) to run pg_repack as follows?

timeout -s SIGINT 180s pg_repack --host=myhost --username=pgrepack_user --dbname=mydb --table=my table --wait-timeout=360

The point is:

  • the pg_repack process will get SIGINT in 180 seconds
  • wait-timeout is set to twice the 180 seconds (or just set it to high enough number of seconds, ie. 999999)
    ...therefore the wait-timeout should never happen and pg_repack should never send pg_cancel_backend() and pg_terminate_backend() - is it right?

Update: could it be possible to add an option for pg_repack to run it in "do not harm anyone" mode - avoiding running pg_cancel/terminate_backend() and after a wait_timeout it just rollback its changes and exit?

Thanks for help,
Jiri

pg_repack compiling fail on Ubuntu 14.04 with apt.postgresql.org packages

pg_repack not compatible with libpq5 9.5 ???

steps to reproduce

wget -q -O- https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" > /etc/apt/source.list.d/pgsql.list
apt-get update
apt-get install libedit-dev libpq-dev postgresql-9.4 postgresql-server-dev-9.4 
pip install --upgrade pgxnclient
pgxn install pg_repack

error output

root@local-coffee-master:~# pgxn install pg_repack
INFO: best version: pg_repack 1.3.2
INFO: saving /tmp/tmpcBVeFA/pg_repack-1.3.2.zip
INFO: unpacking: /tmp/tmpcBVeFA/pg_repack-1.3.2.zip
INFO: building extension
make[1]: Entering directory `/tmp/tmpcBVeFA/pg_repack-1.3.2/bin'
gcc -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 --param=ssp-buffer-size=4 -Wformat -Werror=format-security -I/usr/include/mit-krb5 -fPIC -pie -DLINUX_OOM_SCORE_ADJ=0 -fno-omit-frame-pointer -I/usr/include/postgresql -DREPACK_V
ERSION=1.3.2 -I. -I./ -I/usr/include/postgresql/9.4/server -I/usr/include/postgresql/internal -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2  -I/usr/include/tcl8.6  -c -o pg_repack.o pg_repa
ck.c
In file included from pgut/pgut.h:22:0,
                 from pgut/pgut-fe.h:13,
                 from pg_repack.c:25:
/usr/include/postgresql/internal/pqexpbuffer.h:149:13: warning: no previous prototype for 'printfPQExpBuffer' [-Wmissing-prototypes]
 extern void printfPQExpBuffer(PQExpBuffer str, const char *fmt,...) pg_attribute_printf(2, 3);
             ^
/usr/include/postgresql/internal/pqexpbuffer.h: In function 'printfPQExpBuffer':
/usr/include/postgresql/internal/pqexpbuffer.h:149:69: error: expected declaration specifiers before 'pg_attribute_printf'
 extern void printfPQExpBuffer(PQExpBuffer str, const char *fmt,...) pg_attribute_printf(2, 3);
                                                                     ^
/usr/include/postgresql/internal/pqexpbuffer.h:158:69: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'pg_attribute_printf'
 extern void appendPQExpBuffer(PQExpBuffer str, const char *fmt,...) pg_attribute_printf(2, 3);
                                                                     ^
/usr/include/postgresql/internal/pqexpbuffer.h:165:13: error: storage class specified for parameter 'appendPQExpBufferStr'
 extern void appendPQExpBufferStr(PQExpBuffer str, const char *data);
             ^
/usr/include/postgresql/internal/pqexpbuffer.h:172:13: error: storage class specified for parameter 'appendPQExpBufferChar'
 extern void appendPQExpBufferChar(PQExpBuffer str, char ch);
             ^
/usr/include/postgresql/internal/pqexpbuffer.h:179:13: error: storage class specified for parameter 'appendBinaryPQExpBuffer'
 extern void appendBinaryPQExpBuffer(PQExpBuffer str,
             ^
In file included from /usr/include/setjmp.h:29:0,
                 from /usr/include/postgresql/9.4/server/utils/elog.h:17,
                 from pgut/pgut.h:23,
                 from pgut/pgut-fe.h:13,
                 from pg_repack.c:25:
/usr/include/x86_64-linux-gnu/bits/setjmp.h:31:18: error: storage class specified for parameter '__jmp_buf'
 typedef long int __jmp_buf[8];
                  ^
In file included from /usr/include/postgresql/9.4/server/utils/elog.h:17:0,
                 from pgut/pgut.h:23,
                 from pgut/pgut-fe.h:13,
                 from pg_repack.c:25:
/usr/include/setjmp.h:40:5: error: expected specifier-qualifier-list before '__jmp_buf'
     __jmp_buf __jmpbuf;  /* Calling environment.  */
     ^
/usr/include/setjmp.h:48:30: error: storage class specified for parameter 'jmp_buf'
 typedef struct __jmp_buf_tag jmp_buf[1];
                              ^
/usr/include/setjmp.h:52:20: error: expected declaration specifiers or '...' before 'jmp_buf'
 extern int setjmp (jmp_buf __env) __THROWNL;
                    ^
/usr/include/setjmp.h:59:12: error: storage class specified for parameter '__sigsetjmp'
 extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask) __THROWNL;
            ^
/usr/include/setjmp.h:63:12: error: storage class specified for parameter '_setjmp'
 extern int _setjmp (struct __jmp_buf_tag __env[1]) __THROWNL;
            ^
/usr/include/setjmp.h:74:13: error: storage class specified for parameter 'longjmp'
 extern void longjmp (struct __jmp_buf_tag __env[1], int __val)
             ^
/usr/include/setjmp.h:83:13: error: storage class specified for parameter '_longjmp'
 extern void _longjmp (struct __jmp_buf_tag __env[1], int __val)
             ^
/usr/include/setjmp.h:92:30: error: storage class specified for parameter 'sigjmp_buf'
 typedef struct __jmp_buf_tag sigjmp_buf[1];
                              ^
/usr/include/setjmp.h:102:25: error: expected declaration specifiers or '...' before 'sigjmp_buf'
 extern void siglongjmp (sigjmp_buf __env, int __val)
                         ^
In file included from /usr/include/features.h:374:0,
                 from /usr/include/stdio.h:27,
                 from /usr/include/postgresql/9.4/server/c.h:81,
                 from pgut/pgut.h:13,
                 from pgut/pgut-fe.h:13,
                 from pg_repack.c:25:
/usr/include/x86_64-linux-gnu/bits/setjmp2.h:25:13: error: storage class specified for parameter 'longjmp'
 extern void __REDIRECT_NTHNL (longjmp,
             ^
/usr/include/x86_64-linux-gnu/bits/setjmp2.h:25:13: error: redefinition of parameter 'longjmp'
In file included from /usr/include/postgresql/9.4/server/utils/elog.h:17:0,
                 from pgut/pgut.h:23,
                 from pgut/pgut-fe.h:13,
                 from pg_repack.c:25:
/usr/include/setjmp.h:74:13: note: previous definition of 'longjmp' was here
 extern void longjmp (struct __jmp_buf_tag __env[1], int __val)
             ^
In file included from /usr/include/features.h:374:0,
                 from /usr/include/stdio.h:27,
                 from /usr/include/postgresql/9.4/server/c.h:81,
                 from pgut/pgut.h:13,
                 from pgut/pgut-fe.h:13,
                 from pg_repack.c:25:
/usr/include/x86_64-linux-gnu/bits/setjmp2.h:28:13: error: storage class specified for parameter '_longjmp'
 extern void __REDIRECT_NTHNL (_longjmp,
             ^
/usr/include/x86_64-linux-gnu/bits/setjmp2.h:28:13: error: redefinition of parameter '_longjmp'
In file included from /usr/include/postgresql/9.4/server/utils/elog.h:17:0,
                 from pgut/pgut.h:23,
                 from pgut/pgut-fe.h:13,
                 from pg_repack.c:25:
/usr/include/setjmp.h:83:13: note: previous definition of '_longjmp' was here
 extern void _longjmp (struct __jmp_buf_tag __env[1], int __val)
             ^
In file included from /usr/include/features.h:374:0,
                 from /usr/include/stdio.h:27,
                 from /usr/include/postgresql/9.4/server/c.h:81,
                 from pgut/pgut.h:13,
                 from pgut/pgut-fe.h:13,
                 from pg_repack.c:25:
/usr/include/x86_64-linux-gnu/bits/setjmp2.h:31:13: error: storage class specified for parameter 'siglongjmp'
 extern void __REDIRECT_NTHNL (siglongjmp,
             ^
In file included from pgut/pgut.h:23:0,
                 from pgut/pgut-fe.h:13,
                 from pg_repack.c:25:
/usr/include/postgresql/9.4/server/utils/elog.h:137:13: error: storage class specified for parameter 'errstart'
 extern bool errstart(int elevel, const char *filename, int lineno,
             ^
/usr/include/postgresql/9.4/server/utils/elog.h:139:13: error: storage class specified for parameter 'errfinish'
 extern void errfinish(int dummy,...);
             ^
/usr/include/postgresql/9.4/server/utils/elog.h:141:12: error: storage class specified for parameter 'errcode'
 extern int errcode(int sqlerrcode);
            ^
/usr/include/postgresql/9.4/server/utils/elog.h:143:12: error: storage class specified for parameter 'errcode_for_file_access'
 extern int errcode_for_file_access(void);
            ^
/usr/include/postgresql/9.4/server/utils/elog.h:144:12: error: storage class specified for parameter 'errcode_for_socket_access'
 extern int errcode_for_socket_access(void);
            ^
/usr/include/postgresql/9.4/server/utils/elog.h:147:1: error: storage class specified for parameter 'errmsg'
 errmsg(const char *fmt,...)
 ^
/usr/include/postgresql/9.4/server/utils/elog.h:153:1: error: storage class specified for parameter 'errmsg_internal'
 errmsg_internal(const char *fmt,...)
 ^
/usr/include/postgresql/9.4/server/utils/elog.h:159:1: error: storage class specified for parameter 'errmsg_plural'
 errmsg_plural(const char *fmt_singular, const char *fmt_plural,
 ^
/usr/include/postgresql/9.4/server/utils/elog.h:167:1: error: storage class specified for parameter 'errdetail'
 errdetail(const char *fmt,...)
 ^
/usr/include/postgresql/9.4/server/utils/elog.h:173:1: error: storage class specified for parameter 'errdetail_internal'
 errdetail_internal(const char *fmt,...)
 ^
/usr/include/postgresql/9.4/server/utils/elog.h:179:1: error: storage class specified for parameter 'errdetail_log'
 errdetail_log(const char *fmt,...)
 ^
/usr/include/postgresql/9.4/server/utils/elog.h:185:1: error: storage class specified for parameter 'errdetail_log_plural'
 errdetail_log_plural(const char *fmt_singular, const char *fmt_plural,
 ^
/usr/include/postgresql/9.4/server/utils/elog.h:193:1: error: storage class specified for parameter 'errdetail_plural'
 errdetail_plural(const char *fmt_singular, const char *fmt_plural,
 ^
/usr/include/postgresql/9.4/server/utils/elog.h:201:1: error: storage class specified for parameter 'errhint'
 errhint(const char *fmt,...)
 ^
/usr/include/postgresql/9.4/server/utils/elog.h:216:12: error: storage class specified for parameter 'set_errcontext_domain'
 extern int set_errcontext_domain(const char *domain);
            ^
/usr/include/postgresql/9.4/server/utils/elog.h:218:1: error: storage class specified for parameter 'errcontext_msg'
 errcontext_msg(const char *fmt,...)
 ^
/usr/include/postgresql/9.4/server/utils/elog.h:223:12: error: storage class specified for parameter 'errhidestmt'
 extern int errhidestmt(bool hide_stmt);
            ^
/usr/include/postgresql/9.4/server/utils/elog.h:225:12: error: storage class specified for parameter 'errfunction'
 extern int errfunction(const char *funcname);
            ^
/usr/include/postgresql/9.4/server/utils/elog.h:226:12: error: storage class specified for parameter 'errposition'
 extern int errposition(int cursorpos);
            ^
/usr/include/postgresql/9.4/server/utils/elog.h:228:12: error: storage class specified for parameter 'internalerrposition'
 extern int internalerrposition(int cursorpos);
            ^
/usr/include/postgresql/9.4/server/utils/elog.h:229:12: error: storage class specified for parameter 'internalerrquery'
 extern int internalerrquery(const char *query);
            ^
/usr/include/postgresql/9.4/server/utils/elog.h:231:12: error: storage class specified for parameter 'err_generic_string'
 extern int err_generic_string(int field, const char *str);
            ^
/usr/include/postgresql/9.4/server/utils/elog.h:233:12: error: storage class specified for parameter 'geterrcode'
 extern int geterrcode(void);
            ^
/usr/include/postgresql/9.4/server/utils/elog.h:234:12: error: storage class specified for parameter 'geterrposition'
 extern int geterrposition(void);
            ^
/usr/include/postgresql/9.4/server/utils/elog.h:235:12: error: storage class specified for parameter 'getinternalerrposition'
 extern int getinternalerrposition(void);
            ^
/usr/include/postgresql/9.4/server/utils/elog.h:275:13: error: storage class specified for parameter 'elog_start'
 extern void elog_start(const char *filename, int lineno, const char *funcname);
             ^
/usr/include/postgresql/9.4/server/utils/elog.h:277:1: error: storage class specified for parameter 'elog_finish'
 elog_finish(int elevel, const char *fmt,...)
 ^
/usr/include/postgresql/9.4/server/utils/elog.h:285:13: error: storage class specified for parameter 'pre_format_elog_string'
 extern void pre_format_elog_string(int errnumber, const char *domain);
             ^
/usr/include/postgresql/9.4/server/utils/elog.h:287:1: error: storage class specified for parameter 'format_elog_string'
 format_elog_string(const char *fmt,...)
 ^
/usr/include/postgresql/9.4/server/utils/elog.h:300:3: error: storage class specified for parameter 'ErrorContextCallback'
 } ErrorContextCallback;
   ^
/usr/include/postgresql/9.4/server/utils/elog.h:302:41: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
 extern PGDLLIMPORT ErrorContextCallback *error_context_stack;
                                         ^
/usr/include/postgresql/9.4/server/utils/elog.h:370:31: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
 extern PGDLLIMPORT sigjmp_buf *PG_exception_stack;
                               ^
/usr/include/postgresql/9.4/server/utils/elog.h:411:3: error: storage class specified for parameter 'ErrorData'
 } ErrorData;
   ^
/usr/include/postgresql/9.4/server/utils/elog.h:413:13: error: storage class specified for parameter 'EmitErrorReport'
 extern void EmitErrorReport(void);
             ^
/usr/include/postgresql/9.4/server/utils/elog.h:414:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
 extern ErrorData *CopyErrorData(void);
                  ^
/usr/include/postgresql/9.4/server/utils/elog.h:415:27: error: expected declaration specifiers or '...' before 'ErrorData'
 extern void FreeErrorData(ErrorData *edata);
                           ^
/usr/include/postgresql/9.4/server/utils/elog.h:416:13: error: storage class specified for parameter 'FlushErrorState'
 extern void FlushErrorState(void);
             ^
/usr/include/postgresql/9.4/server/utils/elog.h:417:26: error: expected declaration specifiers or '...' before 'ErrorData'
 extern void ReThrowError(ErrorData *edata) __attribute__((noreturn));
                          ^
/usr/include/postgresql/9.4/server/utils/elog.h:418:13: error: storage class specified for parameter 'pg_re_throw'
 extern void pg_re_throw(void) __attribute__((noreturn));
             ^
/usr/include/postgresql/9.4/server/utils/elog.h:420:14: error: storage class specified for parameter 'GetErrorContextStack'
 extern char *GetErrorContextStack(void);
              ^
/usr/include/postgresql/9.4/server/utils/elog.h:423:37: error: expected declaration specifiers or '...' before 'ErrorData'
 typedef void (*emit_log_hook_type) (ErrorData *edata);
                                     ^
/usr/include/postgresql/9.4/server/utils/elog.h:424:1: error: unknown type name 'emit_log_hook_type'
 extern PGDLLIMPORT emit_log_hook_type emit_log_hook;
 ^
/usr/include/postgresql/9.4/server/utils/elog.h:424:39: error: storage class specified for parameter 'emit_log_hook'
 extern PGDLLIMPORT emit_log_hook_type emit_log_hook;
                                       ^
/usr/include/postgresql/9.4/server/utils/elog.h:434:3: error: storage class specified for parameter 'PGErrorVerbosity'
 } PGErrorVerbosity;
   ^
/usr/include/postgresql/9.4/server/utils/elog.h:436:12: error: storage class specified for parameter 'Log_error_verbosity'
 extern int Log_error_verbosity;
            ^
/usr/include/postgresql/9.4/server/utils/elog.h:437:14: error: storage class specified for parameter 'Log_line_prefix'
 extern char *Log_line_prefix;
              ^
/usr/include/postgresql/9.4/server/utils/elog.h:438:12: error: storage class specified for parameter 'Log_destination'
 extern int Log_destination;
            ^
/usr/include/postgresql/9.4/server/utils/elog.h:439:14: error: storage class specified for parameter 'Log_destination_string'
 extern char *Log_destination_string;
              ^
/usr/include/postgresql/9.4/server/utils/elog.h:448:13: error: storage class specified for parameter 'DebugFileOpen'
 extern void DebugFileOpen(void);
             ^
/usr/include/postgresql/9.4/server/utils/elog.h:449:14: error: storage class specified for parameter 'unpack_sql_state'
 extern char *unpack_sql_state(int sql_state);
              ^
/usr/include/postgresql/9.4/server/utils/elog.h:450:13: error: storage class specified for parameter 'in_error_recursion_trouble'
 extern bool in_error_recursion_trouble(void);
             ^
/usr/include/postgresql/9.4/server/utils/elog.h:453:13: error: storage class specified for parameter 'set_syslog_parameters'
 extern void set_syslog_parameters(const char *ident, int facility);
             ^
/usr/include/postgresql/9.4/server/utils/elog.h:462:1: error: storage class specified for parameter 'write_stderr'
 write_stderr(const char *fmt,...)
 ^
In file included from pgut/pgut-fe.h:13:0,
                 from pg_repack.c:25:
pgut/pgut.h:32:3: error: storage class specified for parameter 'YesNo'
 } YesNo;
   ^
pgut/pgut.h:34:16: error: storage class specified for parameter 'pgut_atexit_callback'
 typedef void (*pgut_atexit_callback)(bool fatal, void *userdata);
                ^
pgut/pgut.h:39:21: error: storage class specified for parameter 'PROGRAM_NAME'
 extern const char  *PROGRAM_NAME;
                     ^
pgut/pgut.h:40:21: error: storage class specified for parameter 'PROGRAM_VERSION'
 extern const char  *PROGRAM_VERSION;
                     ^
pgut/pgut.h:41:21: error: storage class specified for parameter 'PROGRAM_URL'
 extern const char  *PROGRAM_URL;
                     ^
pgut/pgut.h:42:21: error: storage class specified for parameter 'PROGRAM_EMAIL'
 extern const char  *PROGRAM_EMAIL;
                     ^
pgut/pgut.h:47:14: error: storage class specified for parameter 'interrupted'
 extern bool  interrupted;
              ^
pgut/pgut.h:48:13: error: storage class specified for parameter 'pgut_log_level'
 extern int  pgut_log_level;
             ^
pgut/pgut.h:49:13: error: storage class specified for parameter 'pgut_abort_level'
 extern int  pgut_abort_level;
             ^
pgut/pgut.h:50:14: error: storage class specified for parameter 'pgut_echo'
 extern bool  pgut_echo;
              ^
pgut/pgut.h:52:13: error: storage class specified for parameter 'pgut_init'
 extern void pgut_init(int argc, char **argv);
             ^
pgut/pgut.h:53:30: error: expected declaration specifiers or '...' before 'pgut_atexit_callback'
 extern void pgut_atexit_push(pgut_atexit_callback callback, void *userdata);
                              ^
pgut/pgut.h:54:29: error: expected declaration specifiers or '...' before 'pgut_atexit_callback'
 extern void pgut_atexit_pop(pgut_atexit_callback callback, void *userdata);
                             ^
pgut/pgut.h:55:13: error: storage class specified for parameter 'pgut_putenv'
 extern void pgut_putenv(const char *key, const char *value);
             ^
pgut/pgut.h:60:47: error: expected declaration specifiers or '...' before 'YesNo'
 extern PGconn *pgut_connect(const char *info, YesNo prompt, int elevel);
                                               ^
pgut/pgut.h:61:13: error: storage class specified for parameter 'pgut_disconnect'
 extern void pgut_disconnect(PGconn *conn);
             ^
pgut/pgut.h:62:13: error: storage class specified for parameter 'pgut_disconnect_all'
 extern void pgut_disconnect_all(void);
             ^
pgut/pgut.h:63:18: error: storage class specified for parameter 'pgut_execute'
 extern PGresult *pgut_execute(PGconn* conn, const char *query, int nParams, const char **params);
                  ^
pgut/pgut.h:65:23: error: storage class specified for parameter 'pgut_command'
 extern ExecStatusType pgut_command(PGconn* conn, const char *query, int nParams, const char **params);
                       ^
pgut/pgut.h:66:13: error: storage class specified for parameter 'pgut_commit'
 extern bool pgut_commit(PGconn *conn);
             ^
pgut/pgut.h:67:13: error: storage class specified for parameter 'pgut_rollback'
 extern void pgut_rollback(PGconn *conn);
             ^
pgut/pgut.h:68:13: error: storage class specified for parameter 'pgut_send'
 extern bool pgut_send(PGconn* conn, const char *query, int nParams, const char **params);
             ^
pgut/pgut.h:69:12: error: storage class specified for parameter 'pgut_wait'
 extern int pgut_wait(int num, PGconn *connections[], struct timeval *timeout);
            ^
pgut/pgut.h:74:14: error: storage class specified for parameter 'pgut_malloc'
 extern void *pgut_malloc(size_t size);
              ^
pgut/pgut.h:75:14: error: storage class specified for parameter 'pgut_realloc'
 extern void *pgut_realloc(void *p, size_t size);
              ^
pgut/pgut.h:76:14: error: storage class specified for parameter 'pgut_strdup'
 extern char *pgut_strdup(const char *str);
              ^
pgut/pgut.h:77:14: error: storage class specified for parameter 'strdup_with_len'
 extern char *strdup_with_len(const char *str, size_t len);
              ^
pgut/pgut.h:78:14: error: storage class specified for parameter 'strdup_trim'
 extern char *strdup_trim(const char *str);
              ^
pgut/pgut.h:87:14: error: storage class specified for parameter 'pgut_fopen'
 extern FILE *pgut_fopen(const char *path, const char *mode);
              ^
pgut/pgut.h:88:13: error: storage class specified for parameter 'pgut_mkdir'
 extern bool pgut_mkdir(const char *path);
             ^
pgut/pgut.h:101:13: error: storage class specified for parameter 'elog'
 extern void elog(int elevel, const char *fmt, ...)
             ^
pgut/pgut.h:103:20: error: storage class specified for parameter 'format_elevel'
 extern const char *format_elevel(int elevel);
                    ^
pgut/pgut.h:104:12: error: storage class specified for parameter 'parse_elevel'
 extern int parse_elevel(const char *value);
            ^
pgut/pgut.h:105:12: error: storage class specified for parameter 'errcode_errno'
 extern int errcode_errno(void);
            ^
pgut/pgut.h:106:13: error: storage class specified for parameter 'log_required'
 extern bool log_required(int elevel, int log_min_level);
             ^
pgut/pgut.h:107:13: error: storage class specified for parameter 'pgut_errstart'
 extern bool pgut_errstart(int elevel);
             ^
pgut/pgut.h:108:13: error: storage class specified for parameter 'pgut_errfinish'
 extern void pgut_errfinish(int dummy, ...);
             ^
pgut/pgut.h:109:13: error: storage class specified for parameter 'pgut_error'
 extern void pgut_error(int elevel, int code, const char *msg, const char *detail);
             ^
pgut/pgut.h:115:13: error: storage class specified for parameter 'CHECK_FOR_INTERRUPTS'
 extern void CHECK_FOR_INTERRUPTS(void);
             ^
pgut/pgut.h:153:13: error: storage class specified for parameter 'pgut_appendStringInfoVA'
 extern bool pgut_appendStringInfoVA(StringInfo str, const char *fmt, va_list args)
             ^
pgut/pgut.h:155:12: error: storage class specified for parameter 'appendStringInfoFile'
 extern int appendStringInfoFile(StringInfo str, FILE *fp);
            ^
pgut/pgut.h:156:12: error: storage class specified for parameter 'appendStringInfoFd'
 extern int appendStringInfoFd(StringInfo str, int fd);
            ^
pgut/pgut.h:158:13: error: storage class specified for parameter 'parse_bool'
 extern bool parse_bool(const char *value, bool *result);
             ^
pgut/pgut.h:159:13: error: storage class specified for parameter 'parse_bool_with_len'
 extern bool parse_bool_with_len(const char *value, size_t len, bool *result);
             ^
pgut/pgut.h:160:13: error: storage class specified for parameter 'parse_int32'
 extern bool parse_int32(const char *value, int32 *result);
             ^
pgut/pgut.h:161:13: error: storage class specified for parameter 'parse_uint32'
 extern bool parse_uint32(const char *value, uint32 *result);
             ^
pgut/pgut.h:162:13: error: storage class specified for parameter 'parse_int64'
 extern bool parse_int64(const char *value, int64 *result);
             ^
pgut/pgut.h:163:13: error: storage class specified for parameter 'parse_uint64'
 extern bool parse_uint64(const char *value, uint64 *result);
             ^
pgut/pgut.h:164:13: error: storage class specified for parameter 'parse_time'
 extern bool parse_time(const char *value, time_t *time);
             ^
pgut/pgut.h:179:3: error: storage class specified for parameter 'SimpleStringListCell'
 } SimpleStringListCell;
   ^
pgut/pgut.h:183:2: error: expected specifier-qualifier-list before 'SimpleStringListCell'
  SimpleStringListCell *head;
  ^
pgut/pgut.h:185:3: error: storage class specified for parameter 'SimpleStringList'
 } SimpleStringList;
   ^
pgut/pgut.h:187:39: error: expected declaration specifiers or '...' before 'SimpleStringList'
 extern void simple_string_list_append(SimpleStringList *list, const char *val);
                                       ^
pgut/pgut.h:188:39: error: expected declaration specifiers or '...' before 'SimpleStringList'
 extern bool simple_string_list_member(SimpleStringList *list, const char *val);
                                       ^
pgut/pgut.h:189:39: error: expected declaration specifiers or '...' before 'SimpleStringList'
 extern size_t simple_string_list_size(SimpleStringList list);
                                       ^
pgut/pgut.h:195:12: error: storage class specified for parameter 'wait_for_socket'
 extern int wait_for_socket(int sock, struct timeval *timeout);
            ^
pgut/pgut.h:196:12: error: storage class specified for parameter 'wait_for_sockets'
 extern int wait_for_sockets(int nfds, fd_set *fds, struct timeval *timeout);
            ^
In file included from pg_repack.c:25:0:
pgut/pgut-fe.h:22:3: error: storage class specified for parameter 'pgut_optsrc'
 } pgut_optsrc;
   ^
pgut/pgut-fe.h:45:2: error: expected specifier-qualifier-list before 'pgut_optsrc'
  pgut_optsrc allowed; /* allowed source */
  ^
pgut/pgut-fe.h:47:3: error: storage class specified for parameter 'pgut_option'
 } pgut_option;
   ^
pgut/pgut-fe.h:49:29: error: expected declaration specifiers or '...' before 'pgut_option'
 typedef void (*pgut_optfn) (pgut_option *opt, const char *arg);
                             ^
pgut/pgut-fe.h:56:3: error: storage class specified for parameter 'worker_conns'
 } worker_conns;
   ^
pgut/pgut-fe.h:60:17: error: storage class specified for parameter 'dbname'
 extern char    *dbname;
                 ^
pgut/pgut-fe.h:61:17: error: storage class specified for parameter 'host'
 extern char    *host;
                 ^
pgut/pgut-fe.h:62:17: error: storage class specified for parameter 'port'
 extern char    *port;
                 ^
pgut/pgut-fe.h:63:17: error: storage class specified for parameter 'username'
 extern char    *username;
                 ^
pgut/pgut-fe.h:64:17: error: storage class specified for parameter 'password'
 extern char    *password;
                 ^
pgut/pgut-fe.h:65:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'prompt_password'
 extern YesNo prompt_password;
              ^
pgut/pgut-fe.h:67:19: error: storage class specified for parameter 'connection'
 extern PGconn    *connection;
                   ^
pgut/pgut-fe.h:68:21: error: storage class specified for parameter 'conn2'
 extern PGconn      *conn2;
                     ^
pgut/pgut-fe.h:69:21: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'workers'
 extern worker_conns workers;
                     ^
pgut/pgut-fe.h:71:13: error: storage class specified for parameter 'pgut_help'
 extern void pgut_help(bool details);
             ^
pgut/pgut-fe.h:72:13: error: storage class specified for parameter 'help'
 extern void help(bool details);
             ^
pgut/pgut-fe.h:74:13: error: storage class specified for parameter 'disconnect'
 extern void disconnect(void);
             ^
pgut/pgut-fe.h:75:13: error: storage class specified for parameter 'reconnect'
 extern void reconnect(int elevel);
             ^
pgut/pgut-fe.h:76:13: error: storage class specified for parameter 'setup_workers'
 extern void setup_workers(int num_workers);
             ^
pgut/pgut-fe.h:77:13: error: storage class specified for parameter 'disconnect_workers'
 extern void disconnect_workers(void);
             ^
pgut/pgut-fe.h:78:18: error: storage class specified for parameter 'execute'
 extern PGresult *execute(const char *query, int nParams, const char **params);
                  ^
pgut/pgut-fe.h:79:18: error: storage class specified for parameter 'execute_elevel'
 extern PGresult *execute_elevel(const char *query, int nParams, const char **params, int elevel);
                  ^
pgut/pgut-fe.h:80:23: error: storage class specified for parameter 'command'
 extern ExecStatusType command(const char *query, int nParams, const char **params);
                       ^
pgut/pgut-fe.h:82:47: error: expected declaration specifiers or '...' before 'pgut_option'
 extern int pgut_getopt(int argc, char **argv, pgut_option options[]);
                                               ^
pgut/pgut-fe.h:83:44: error: expected declaration specifiers or '...' before 'pgut_option'
 extern void pgut_readopt(const char *path, pgut_option options[], int elevel);
                                            ^
pgut/pgut-fe.h:84:25: error: expected declaration specifiers or '...' before 'pgut_option'
 extern void pgut_setopt(pgut_option *opt, const char *optarg, pgut_optsrc src);
                         ^
pgut/pgut-fe.h:84:63: error: expected declaration specifiers or '...' before 'pgut_optsrc'
 extern void pgut_setopt(pgut_option *opt, const char *optarg, pgut_optsrc src);
                                                               ^
pgut/pgut-fe.h:85:13: error: storage class specified for parameter 'pgut_keyeq'
 extern bool pgut_keyeq(const char *lhs, const char *rhs);
             ^
In file included from /usr/include/time.h:41:0,
                 from pg_repack.c:31:
/usr/include/x86_64-linux-gnu/bits/time.h:91:12: error: storage class specified for parameter 'clock_adjtime'
 extern int clock_adjtime (__clockid_t __clock_id, struct timex *__utx) __THROW;
            ^
In file included from pg_repack.c:31:0:
/usr/include/time.h:189:16: error: storage class specified for parameter 'clock'
 extern clock_t clock (void) __THROW;
                ^
/usr/include/time.h:192:15: error: storage class specified for parameter 'time'
 extern time_t time (time_t *__timer) __THROW;
               ^
/usr/include/time.h:195:15: error: storage class specified for parameter 'difftime'
 extern double difftime (time_t __time1, time_t __time0)
               ^
/usr/include/time.h:199:15: error: storage class specified for parameter 'mktime'
 extern time_t mktime (struct tm *__tp) __THROW;
               ^
/usr/include/time.h:205:15: error: storage class specified for parameter 'strftime'
 extern size_t strftime (char *__restrict __s, size_t __maxsize,
               ^
/usr/include/time.h:213:14: error: storage class specified for parameter 'strptime'
 extern char *strptime (const char *__restrict __s,
              ^
/usr/include/time.h:223:15: error: storage class specified for parameter 'strftime_l'
 extern size_t strftime_l (char *__restrict __s, size_t __maxsize,
               ^
/usr/include/time.h:230:14: error: storage class specified for parameter 'strptime_l'
 extern char *strptime_l (const char *__restrict __s,
              ^
/usr/include/time.h:239:19: error: storage class specified for parameter 'gmtime'
 extern struct tm *gmtime (const time_t *__timer) __THROW;
                   ^
/usr/include/time.h:243:19: error: storage class specified for parameter 'localtime'
 extern struct tm *localtime (const time_t *__timer) __THROW;
                   ^
/usr/include/time.h:249:19: error: storage class specified for parameter 'gmtime_r'
 extern struct tm *gmtime_r (const time_t *__restrict __timer,
                   ^
/usr/include/time.h:254:19: error: storage class specified for parameter 'localtime_r'
 extern struct tm *localtime_r (const time_t *__restrict __timer,
                   ^
/usr/include/time.h:261:14: error: storage class specified for parameter 'asctime'
 extern char *asctime (const struct tm *__tp) __THROW;
              ^
/usr/include/time.h:264:14: error: storage class specified for parameter 'ctime'
 extern char *ctime (const time_t *__timer) __THROW;
              ^
/usr/include/time.h:272:14: error: storage class specified for parameter 'asctime_r'
 extern char *asctime_r (const struct tm *__restrict __tp,
              ^
/usr/include/time.h:276:14: error: storage class specified for parameter 'ctime_r'
 extern char *ctime_r (const time_t *__restrict __timer,
              ^
/usr/include/time.h:282:14: error: storage class specified for parameter '__tzname'
 extern char *__tzname[2]; /* Current timezone names.  */
              ^
/usr/include/time.h:283:12: error: storage class specified for parameter '__daylight'
 extern int __daylight;  /* If daylight-saving time is ever in use.  */
            ^
/usr/include/time.h:284:17: error: storage class specified for parameter '__timezone'
 extern long int __timezone; /* Seconds west of UTC.  */
                 ^
/usr/include/time.h:289:14: error: storage class specified for parameter 'tzname'
 extern char *tzname[2];
              ^
/usr/include/time.h:293:13: error: storage class specified for parameter 'tzset'
 extern void tzset (void) __THROW;
             ^
/usr/include/time.h:297:12: error: storage class specified for parameter 'daylight'
 extern int daylight;
            ^
/usr/include/time.h:298:17: error: storage class specified for parameter 'timezone'
 extern long int timezone;
                 ^
/usr/include/time.h:304:12: error: storage class specified for parameter 'stime'
 extern int stime (const time_t *__when) __THROW;
            ^
/usr/include/time.h:319:15: error: storage class specified for parameter 'timegm'
 extern time_t timegm (struct tm *__tp) __THROW;
               ^
/usr/include/time.h:322:15: error: storage class specified for parameter 'timelocal'
 extern time_t timelocal (struct tm *__tp) __THROW;
               ^
/usr/include/time.h:325:12: error: storage class specified for parameter 'dysize'
 extern int dysize (int __year) __THROW  __attribute__ ((__const__));
            ^
/usr/include/time.h:334:12: error: storage class specified for parameter 'nanosleep'
 extern int nanosleep (const struct timespec *__requested_time,
            ^
/usr/include/time.h:339:12: error: storage class specified for parameter 'clock_getres'
 extern int clock_getres (clockid_t __clock_id, struct timespec *__res) __THROW;
            ^
/usr/include/time.h:342:12: error: storage class specified for parameter 'clock_gettime'
 extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __THROW;
            ^
/usr/include/time.h:345:12: error: storage class specified for parameter 'clock_settime'
 extern int clock_settime (clockid_t __clock_id, const struct timespec *__tp)
            ^
/usr/include/time.h:353:12: error: storage class specified for parameter 'clock_nanosleep'
 extern int clock_nanosleep (clockid_t __clock_id, int __flags,
            ^
/usr/include/time.h:358:12: error: storage class specified for parameter 'clock_getcpuclockid'
 extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) __THROW;
            ^
/usr/include/time.h:363:12: error: storage class specified for parameter 'timer_create'
 extern int timer_create (clockid_t __clock_id,
            ^
/usr/include/time.h:368:12: error: storage class specified for parameter 'timer_delete'
 extern int timer_delete (timer_t __timerid) __THROW;
            ^
/usr/include/time.h:371:12: error: storage class specified for parameter 'timer_settime'
 extern int timer_settime (timer_t __timerid, int __flags,
            ^
/usr/include/time.h:376:12: error: storage class specified for parameter 'timer_gettime'
 extern int timer_gettime (timer_t __timerid, struct itimerspec *__value)
            ^
/usr/include/time.h:380:12: error: storage class specified for parameter 'timer_getoverrun'
 extern int timer_getoverrun (timer_t __timerid) __THROW;
            ^
/usr/include/time.h:386:12: error: storage class specified for parameter 'timespec_get'
 extern int timespec_get (struct timespec *__ts, int __base)
            ^
/usr/include/time.h:403:12: error: storage class specified for parameter 'getdate_err'
 extern int getdate_err;
            ^
/usr/include/time.h:412:19: error: storage class specified for parameter 'getdate'
 extern struct tm *getdate (const char *__string);
                   ^
/usr/include/time.h:426:12: error: storage class specified for parameter 'getdate_r'
 extern int getdate_r (const char *__restrict __string,
            ^
In file included from /usr/include/poll.h:1:0,
                 from pg_repack.c:35:
/usr/include/x86_64-linux-gnu/sys/poll.h:36:27: error: storage class specified for parameter 'nfds_t'
 typedef unsigned long int nfds_t;
                           ^
/usr/include/x86_64-linux-gnu/sys/poll.h:57:40: error: expected declaration specifiers or '...' before 'nfds_t'
 extern int poll (struct pollfd *__fds, nfds_t __nfds, int __timeout);
                                        ^
/usr/include/x86_64-linux-gnu/sys/poll.h:66:41: error: expected declaration specifiers or '...' before 'nfds_t'
 extern int ppoll (struct pollfd *__fds, nfds_t __nfds,
                                         ^
In file included from /usr/include/features.h:374:0,
                 from /usr/include/stdio.h:27,
                 from /usr/include/postgresql/9.4/server/c.h:81,
                 from pgut/pgut.h:13,
                 from pgut/pgut-fe.h:13,
                 from pg_repack.c:25:
/usr/include/x86_64-linux-gnu/bits/poll2.h:26:12: error: expected declaration specifiers or '...' before 'nfds_t'
 extern int __REDIRECT (__poll_alias, (struct pollfd *__fds, nfds_t __nfds,
            ^
In file included from /usr/include/x86_64-linux-gnu/sys/poll.h:76:0,
                 from /usr/include/poll.h:1,
                 from pg_repack.c:35:
/usr/include/x86_64-linux-gnu/bits/poll2.h:28:46: error: expected declaration specifiers or '...' before 'nfds_t'
 extern int __poll_chk (struct pollfd *__fds, nfds_t __nfds, int __timeout,
                                              ^
In file included from /usr/include/features.h:374:0,
                 from /usr/include/stdio.h:27,
                 from /usr/include/postgresql/9.4/server/c.h:81,
                 from pgut/pgut.h:13,
                 from pgut/pgut-fe.h:13,
                 from pg_repack.c:25:
/usr/include/x86_64-linux-gnu/bits/poll2.h:30:12: error: expected declaration specifiers or '...' before 'nfds_t'
 extern int __REDIRECT (__poll_chk_warn, (struct pollfd *__fds, nfds_t __nfds,
            ^
In file included from /usr/include/x86_64-linux-gnu/sys/poll.h:76:0,
                 from /usr/include/poll.h:1,
                 from pg_repack.c:35:
/usr/include/x86_64-linux-gnu/bits/poll2.h:36:29: error: expected declaration specifiers or '...' before 'nfds_t'
 poll (struct pollfd *__fds, nfds_t __nfds, int __timeout)
                             ^
In file included from /usr/include/features.h:374:0,
                 from /usr/include/stdio.h:27,
                 from /usr/include/postgresql/9.4/server/c.h:81,
                 from pgut/pgut.h:13,
                 from pgut/pgut-fe.h:13,
                 from pg_repack.c:25:
/usr/include/x86_64-linux-gnu/bits/poll2.h:51:12: error: expected declaration specifiers or '...' before 'nfds_t'
 extern int __REDIRECT (__ppoll_alias, (struct pollfd *__fds, nfds_t __nfds,
            ^
In file included from /usr/include/x86_64-linux-gnu/sys/poll.h:76:0,
                 from /usr/include/poll.h:1,
                 from pg_repack.c:35:
/usr/include/x86_64-linux-gnu/bits/poll2.h:54:47: error: expected declaration specifiers or '...' before 'nfds_t'
 extern int __ppoll_chk (struct pollfd *__fds, nfds_t __nfds,
                                               ^
In file included from /usr/include/features.h:374:0,
                 from /usr/include/stdio.h:27,
                 from /usr/include/postgresql/9.4/server/c.h:81,
                 from pgut/pgut.h:13,
                 from pgut/pgut-fe.h:13,
                 from pg_repack.c:25:
/usr/include/x86_64-linux-gnu/bits/poll2.h:57:12: error: expected declaration specifiers or '...' before 'nfds_t'
 extern int __REDIRECT (__ppoll_chk_warn, (struct pollfd *__fds, nfds_t __nfds,
            ^
In file included from /usr/include/x86_64-linux-gnu/sys/poll.h:76:0,
                 from /usr/include/poll.h:1,
                 from pg_repack.c:35:
/usr/include/x86_64-linux-gnu/bits/poll2.h:65:30: error: expected declaration specifiers or '...' before 'nfds_t'
 ppoll (struct pollfd *__fds, nfds_t __nfds, const struct timespec *__timeout,
                              ^
pg_repack.c:156:3: error: storage class specified for parameter 'index_status_t'
 } index_status_t;
   ^
pg_repack.c:165:5: error: expected specifier-qualifier-list before 'index_status_t'
     index_status_t  status;   /* Track parallel build statuses. */
     ^
pg_repack.c:167:3: error: storage class specified for parameter 'repack_index'
 } repack_index;
   ^
pg_repack.c:194:2: error: expected specifier-qualifier-list before 'repack_index'
  repack_index   *indexes;        /* info on each index */
  ^
pg_repack.c:195:3: error: storage class specified for parameter 'repack_table'
 } repack_table;
   ^
pg_repack.c:198:13: error: storage class specified for parameter 'is_superuser'
 static bool is_superuser(void);
             ^
pg_repack.c:199:13: error: storage class specified for parameter 'check_tablespace'
 static void check_tablespace(void);
             ^
pg_repack.c:200:13: error: storage class specified for parameter 'preliminary_checks'
 static bool preliminary_checks(char *errbuf, size_t errsize);
             ^
pg_repack.c:201:13: error: storage class specified for parameter 'repack_all_databases'
 static void repack_all_databases(const char *order_by);
             ^
pg_repack.c:202:13: error: storage class specified for parameter 'repack_one_database'
 static bool repack_one_database(const char *order_by, char *errbuf, size_t errsize);
             ^
pg_repack.c:203:30: error: expected declaration specifiers or '...' before 'repack_table'
 static void repack_one_table(repack_table *table, const char *order_by);
                              ^
pg_repack.c:204:13: error: storage class specified for parameter 'repack_table_indexes'
 static bool repack_table_indexes(PGresult *index_details);
             ^
pg_repack.c:205:13: error: storage class specified for parameter 'repack_all_indexes'
 static bool repack_all_indexes(char *errbuf, size_t errsize);
             ^
pg_repack.c:206:46: warning: type defaults to 'int' in declaration of 'repack_table' [-Wimplicit-int]
 static void repack_cleanup(bool fatal, const repack_table *table);
                                              ^
pg_repack.c:206:59: error: expected ';', ',' or ')' before '*' token
 static void repack_cleanup(bool fatal, const repack_table *table);
                                                           ^
pg_repack.c:207:13: error: storage class specified for parameter 'repack_cleanup_callback'
 static void repack_cleanup_callback(bool fatal, void *userdata);
             ^
pg_repack.c:208:35: warning: type defaults to 'int' in declaration of 'repack_table' [-Wimplicit-int]
 static bool rebuild_indexes(const repack_table *table);
                                   ^
pg_repack.c:208:48: error: expected ';', ',' or ')' before '*' token
 static bool rebuild_indexes(const repack_table *table);
                                                ^
pg_repack.c:210:14: error: storage class specified for parameter 'getstr'
 static char *getstr(PGresult *res, int row, int col);
              ^
pg_repack.c:211:12: error: storage class specified for parameter 'getoid'
 static Oid getoid(PGresult *res, int row, int col);
            ^
pg_repack.c:212:13: error: storage class specified for parameter 'advisory_lock'
 static bool advisory_lock(PGconn *conn, const char *relid);
             ^
pg_repack.c:213:13: error: storage class specified for parameter 'lock_exclusive'
 static bool lock_exclusive(PGconn *conn, const char *relid, const char *lock_query, bool start_xact);
             ^
pg_repack.c:214:13: error: storage class specified for parameter 'kill_ddl'
 static bool kill_ddl(PGconn *conn, Oid relid, bool terminate);
             ^
pg_repack.c:215:13: error: storage class specified for parameter 'lock_access_share'
 static bool lock_access_share(PGconn *conn, Oid relid, const char *target_name);
             ^
pg_repack.c:222:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
 {
 ^
pg_repack.c:226:16: error: storage class specified for parameter 'analyze'
 static bool    analyze = true;
                ^
pg_repack.c:226:1: error: parameter 'analyze' is initialized
 static bool    analyze = true;
 ^
pg_repack.c:227:16: error: storage class specified for parameter 'alldb'
 static bool    alldb = false;
                ^
pg_repack.c:227:1: error: parameter 'alldb' is initialized
 static bool    alldb = false;
 ^
pg_repack.c:228:16: error: storage class specified for parameter 'noorder'
 static bool    noorder = false;
                ^
pg_repack.c:228:1: error: parameter 'noorder' is initialized
 static bool    noorder = false;
 ^
pg_repack.c:229:25: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'table_list'
 static SimpleStringList table_list = {NULL, NULL};
                         ^
pg_repack.c:229:50: error: expected declaration specifiers before ';' token
 static SimpleStringList table_list = {NULL, NULL};
                                                  ^
pg_repack.c:230:25: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'schema_list'
 static SimpleStringList schema_list = {NULL, NULL};
                         ^
pg_repack.c:230:51: error: expected declaration specifiers before ';' token
 static SimpleStringList schema_list = {NULL, NULL};
                                                   ^
pg_repack.c:231:17: error: storage class specified for parameter 'orderby'
 static char    *orderby = NULL;
                 ^
pg_repack.c:231:1: error: parameter 'orderby' is initialized
 static char    *orderby = NULL;
 ^
pg_repack.c:232:17: error: storage class specified for parameter 'tablespace'
 static char    *tablespace = NULL;
                 ^
pg_repack.c:232:1: error: parameter 'tablespace' is initialized
 static char    *tablespace = NULL;
 ^
pg_repack.c:233:16: error: storage class specified for parameter 'moveidx'
 static bool    moveidx = false;
                ^
pg_repack.c:233:1: error: parameter 'moveidx' is initialized
 static bool    moveidx = false;
 ^
pg_repack.c:234:25: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'r_index'
 static SimpleStringList r_index = {NULL, NULL};
                         ^
pg_repack.c:234:47: error: expected declaration specifiers before ';' token
 static SimpleStringList r_index = {NULL, NULL};
                                               ^
pg_repack.c:235:16: error: storage class specified for parameter 'only_indexes'
 static bool    only_indexes = false;
                ^
pg_repack.c:235:1: error: parameter 'only_indexes' is initialized
 static bool    only_indexes = false;
 ^
pg_repack.c:236:15: error: storage class specified for parameter 'wait_timeout'
 static int    wait_timeout = 60; /* in seconds */
               ^
pg_repack.c:236:1: error: parameter 'wait_timeout' is initialized
 static int    wait_timeout = 60; /* in seconds */
 ^
pg_repack.c:237:15: error: storage class specified for parameter 'jobs'
 static int    jobs = 0; /* number of concurrent worker conns. */
               ^
pg_repack.c:237:1: error: parameter 'jobs' is initialized
 static int    jobs = 0; /* number of concurrent worker conns. */
 ^
pg_repack.c:238:16: error: storage class specified for parameter 'dryrun'
 static bool    dryrun = false;
                ^
pg_repack.c:238:1: error: parameter 'dryrun' is initialized
 static bool    dryrun = false;
 ^
pg_repack.c:239:22: error: storage class specified for parameter 'temp_obj_num'
 static unsigned int  temp_obj_num = 0; /* temporary objects counter */
                      ^
pg_repack.c:239:1: error: parameter 'temp_obj_num' is initialized
 static unsigned int  temp_obj_num = 0; /* temporary objects counter */
 ^
pg_repack.c:244:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
 {
 ^
pg_repack.c:250:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'options'
 static pgut_option options[] =
                    ^
pg_repack.c:266:2: error: expected declaration specifiers before ';' token
 };
  ^
pg_repack.c:270:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
 {
 ^
pg_repack.c:364:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
 {
 ^
pg_repack.c:385:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
 {
 ^
pg_repack.c:433:49: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
 preliminary_checks(char *errbuf, size_t errsize){
                                                 ^
pg_repack.c:521:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
 {
 ^
pg_repack.c:556:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
 {
 ^
pg_repack.c:565:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
 {
 ^
pg_repack.c:577:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
 {
 ^
pg_repack.c:760:31: warning: type defaults to 'int' in declaration of 'repack_table' [-Wimplicit-int]
 apply_log(PGconn *conn, const repack_table *table, int count)
                               ^
pg_repack.c:760:44: error: expected ';', ',' or ')' before '*' token
 apply_log(PGconn *conn, const repack_table *table, int count)
                                            ^
pg_repack.c:788:23: warning: type defaults to 'int' in declaration of 'repack_table' [-Wimplicit-int]
 rebuild_indexes(const repack_table *table)
                       ^
pg_repack.c:788:36: error: expected ';', ',' or ')' before '*' token
 rebuild_indexes(const repack_table *table)
                                    ^
pg_repack.c:1000:18: error: expected declaration specifiers or '...' before 'repack_table'
 repack_one_table(repack_table *table, const char *orderby)
                  ^
pg_repack.c:1449:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
 {
 ^
pg_repack.c:1505:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
 {
 ^
pg_repack.c:1577:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
 {
 ^
pg_repack.c:1620:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
 {
 ^
pg_repack.c:1702:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
 {
 ^
pg_repack.c:1728:34: warning: type defaults to 'int' in declaration of 'repack_table' [-Wimplicit-int]
 repack_cleanup(bool fatal, const repack_table *table)
                                  ^
pg_repack.c:1728:47: error: expected ';', ',' or ')' before '*' token
 repack_cleanup(bool fatal, const repack_table *table)
                                               ^
pg_repack.c:1758:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
 {
 ^
pg_repack.c:1952:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
 {
 ^
pg_repack.c:2030:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
 {
 ^
In file included from pgut/pgut.h:22:0,
                 from pgut/pgut-fe.h:13,
                 from pg_repack.c:25:
/usr/include/postgresql/internal/pqexpbuffer.h:149:13: error: old-style parameter declarations in prototyped function definition
 extern void printfPQExpBuffer(PQExpBuffer str, const char *fmt,...) pg_attribute_printf(2, 3);
             ^
pg_repack.c:2052:1: error: expected '{' at end of input
 }
 ^
make[1]: *** [pg_repack.o] Error 1
make[1]: Leaving directory `/tmp/tmpcBVeFA/pg_repack-1.3.2/bin'
make: *** [all] Error 2
ERROR: command returned 2: make PG_CONFIG=/usr/bin/pg_config all

Rebuilding indexes only on Postgres 9.1

I rebuild the indexes of a table using the following command:
pg_repack -x -t tablename dbname

I received the following error:
ERROR: query failed: ERROR: syntax error at or near "CONCURRENTLY"
LINE 1: DROP INDEX CONCURRENTLY "public"."index_278012770"

The CONCURRENTLY keyword for the DROP INDEX statement was only introduced in PostgreSQL 9.2.
http://www.postgresql.org/docs/9.1/static/sql-dropindex.html
http://www.postgresql.org/docs/9.2/static/sql-dropindex.html

Segmentation fault

I installed pg_repack-ver_1.3.2 in a Ubuntu 12.04 Server according to the instructions without a problem. However, when running pg_repack I got segmentation fault.

This is the command I ran:
/usr/lib/postgresql/9.4/bin/pg_repack --host=127.0.0.1 --port=5433 --dbname=db_test --table=test_table --jobs=24 --echo

This is the last part of the LOG (stdout): (From echo)
LOG: (param:4) = DELETE FROM repack.log_57885 WHERE id IN (
LOG: (param:5) = 0
LOG: (query) SELECT repack.repack_swap($1)
LOG: (param:0) = 57885
ERROR: query failed: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
DETAIL: query was: SELECT repack.repack_swap($1)
ERROR: could not connect to database with "dbname=db_test host=127.0.0.1 port=5433 ": FATAL: the database system is in recovery mode
ERROR: could not connect to database with "dbname=db_test host=127.0.0.1 port=5433 ": FATAL: the database system is in recovery mode

In the postgres log file:
2015-10-23 17:58:57 UTC [7050-7/2-33] postgres@db_test STATEMENT: CREATE UNIQUE INDEX index_58036 ON repack.table_58022 USING btree (guid)
2015-10-23 17:58:57 UTC [7050-7/0-34] postgres@db_test LOG: duration: 5706020.641 ms
2015-10-23 17:58:59 UTC [5861--5] LOG: server process (PID 7046) was terminated by signal 11: Segmentation fault
2015-10-23 17:58:59 UTC [5861--6] DETAIL: Failed process was running: SELECT repack.repack_swap($1)
2015-10-23 17:58:59 UTC [5861--7] LOG: terminating any other active server processes
2015-10-23 17:58:59 UTC [33368-29/0-1] postgres@db_test WARNING: terminating connection because of crash of another server process
2015-10-23 17:58:59 UTC [33368-29/0-2] postgres@db_test DETAIL: The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2015-10-23 17:58:59 UTC [33368-29/0-3] postgres@db_test HINT: In a moment you should be able to reconnect to the database and repeat your command.
2015-10-23 17:58:59 UTC [7070-27/0-1] postgres@db_test WARNING: terminating connection because of crash of another server process

In the Syslog file:
Oct 23 17:49:17 xx-xxx-postgres_db kernel: [23706986.017998] postgres[14753]: segfault at e2a6 ip 00007f1339cef761 sp 00007ffff0270248 error 4 in libc-2.15.so[7f1339b8d000+1b4000]

2015-10-23 23:49:17 UTC [5861--11] LOG: server process (PID 14753) was terminated by signal 11: Segmentation fault

Versions:
OS: Ubuntu 12.04
PG: 9.4
REPACK: pg_repack-ver_1.3.2 compile from source

Thanks for this project.

FREEZE'ing with pg_repack

Hi!

I've been using pg_repack for some time now as a scheduled vacuum/cluster for big tables in the small hours of a very busy OLTP database. It also happens this database has a big "transaction log" table that takes more than a day to vacuum, blocking transactions and needing to be cancelled. We then need to dump/restore this table periodically to avoid XID wraparound issues, thus stopping all transactions for six hours or so.

If pg_repack rewrites the whole table and its indexes, shouldn't it reduce the transaction ID age of the live tuples it keeps? Is it possible in any circumstances to use it as an online VACUUM FREEZE?

Thanks!
Bruno

Deadlock detected after pg_repack receives SIGINT

I'm running a pg_repack from a bash script with timeout of 10 minutes like so (simplified version):
timeout -s SIGINT 10m pg_repack --table=frequently_updated_table

After the 10 min timeout, the OS sends SIGINT to pg_repack process so the pg_repack calls:
SELECT repack.repack_drop($1, $2)
and it causes a deadlock with other process which is INSERTing into frequently_updated_table that has a pg_repack's trigger to log every change to a repack.log_[OID of frequently_updated_table].

Is it a bug of pg_repack or am I doing something wrong? Should I add some detailed info?

Thank You for any help,
Jiri

Update: pg_repack version 1.3.2

Cannot find -ledit during make

During build on Ubunt12.04 I'm getting this error:

gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -I/usr/include/mit-krb5 -fPIC -pie -DLINUX_OOM_SCORE_ADJ=0 -fno-omit-frame-pointer -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g pg_repack.o pgut/pgut.o pgut/pgut-fe.o -L/usr/lib/x86_64-linux-gnu -lpq -L/usr/lib/x86_64-linux-gnu -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -L/usr/lib/mit-krb5 -L/usr/lib/x86_64-linux-gnu/mit-krb5 -L/usr/lib/x86_64-linux-gnu -Wl,--as-needed -lpgport -lpgcommon -lssl -lcrypto -lkrb5 -lcom_err -lgssapi_krb5 -lz -ledit -lcrypt -ldl -lm -o pg_repack
/usr/bin/ld: cannot find -ledit
collect2: ld returned 1 exit status
make[1]: *** [pg_repack] Error 1
make[1]: Leaving directory `/home/mkrtich/pg_repack-1.3.1/bin'
make: *** [all] Error 2

What library is -ledit?
BTW After linking manually by removing -ledit it works fine.

Document pg_repack behavior

Hi,

while looking for a documentation of what pg_repack does internally I stumbled over http://www.depesz.com/2011/07/06/bloat-happens/

In there the @depesz writes:

Full procedure looks like this:

  • create log table for changes
  • create triggers on old table to log changes
  • create new table with copy of all data in old table
  • create all indexes on new table
  • apply all changes from log table to new table
  • switch (in system catalogs) information about table files
  • drop old table

Is this still true for pg_repack? If so, it would be great if this could be mentioned in the docs.

Changelog for pg_repack 1.3.3

Hello,

there is no changelog for the new version 1.3.3 (or I can't find it), there is a changelog up to version 1.3.1 (http://reorg.github.io/pg_repack/) but not for the current version. Can I find it somewhere?

I'm happy the 1.3.3 adressess this bug: #55 (and #56) but I'd like to know about all changes since 1.3.2.

Thanky You,
Jiri

Version in control file in HEAD

pg_repack HEAD built against PostgreSQL HEAD. Trying to CREATE EXTENSION - I get an error:

ERROR: could not stat file "$INSTALLDIR/share/extension/pg_repack--1.3-dev0.sql": No such file or directory

install command is:

/usr/bin/install -c -m 644 pg_repack--1.3.1.sql pg_repack.control '$INSTALLDIR/share/extension/'

Missing Makefile magic? Or am I missing some instruction?

Ignore other pg_repack clients in SQL_XID_SNAPSHOT

Thibaud WALKOWIAK complained recently about pg_repack clients having to wait on each other while concurrently operating on tables in the same database. Presumably this wait comes from the SQL_XID_SNAPSHOT check, which does not bother ignoring other pg_repack clients based on application_name.

I proposed a simple fix to have SQL_XID_SNAPSHOT ignore other pg_repack clients using pg_stat_activity.application_name here:
http://lists.pgfoundry.org/pipermail/reorg-general/2012-November/000137.html

(Will only help on 9.0 or later, since that's when we have application_name exposed.)

pg_repack-1.1.8 does not compile against postgresql-9.3.1

failed to compile recent pg_repack against a 9.3.1-1.pgdg70+1 from apt.postgresql.org

make[1]: Entering directory `/home/pfote/src/pg_repack-1.1.8/bin'
gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fPIC -pie -I/usr/include/mit-krb5 -DLINUX_OOM_ADJ=0 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -I/usr/include/postgresql -I. -I./ -I/usr/include/postgresql/9.3/server -I/usr/include/postgresql/internal -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2  -I/usr/include/tcl8.5  -c -o pg_repack.o pg_repack.c
gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fPIC -pie -I/usr/include/mit-krb5 -DLINUX_OOM_ADJ=0 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -I/usr/include/postgresql -I. -I./ -I/usr/include/postgresql/9.3/server -I/usr/include/postgresql/internal -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2  -I/usr/include/tcl8.5  -c -o pgut/pgut.o pgut/pgut.c
gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fPIC -pie -I/usr/include/mit-krb5 -DLINUX_OOM_ADJ=0 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -I/usr/include/postgresql -I. -I./ -I/usr/include/postgresql/9.3/server -I/usr/include/postgresql/internal -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2  -I/usr/include/tcl8.5  -c -o pgut/pgut-fe.o pgut/pgut-fe.c
gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fPIC -pie -I/usr/include/mit-krb5 -DLINUX_OOM_ADJ=0 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g pg_repack.o pgut/pgut.o pgut/pgut-fe.o -L/usr/lib -lpq -L/usr/lib -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -L/usr/lib/mit-krb5 -L/usr/lib/x86_64-linux-gnu/mit-krb5 -L/usr/lib  -Wl,--as-needed  -lpgport -lpgcommon -lpam -lssl -lcrypto -lkrb5 -lcom_err -lgssapi_krb5 -lz -ledit -lcrypt -ldl -lm -o pg_repack
make[1]: Leaving directory `/home/pfote/src/pg_repack-1.1.8/bin'
make[1]: Entering directory `/home/pfote/src/pg_repack-1.1.8/lib'
gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fPIC -pie -I/usr/include/mit-krb5 -DLINUX_OOM_ADJ=0 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -fpic -I. -I./ -I/usr/include/postgresql/9.3/server -I/usr/include/postgresql/internal -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2  -I/usr/include/tcl8.5  -c -o repack.o repack.c
repack.c: In function ‘repack_swap’:
repack.c:742:3: error: too few arguments to function ‘RenameRelationInternal’
In file included from repack.c:22:0:
/usr/include/postgresql/9.3/server/commands/tablecmds.h:60:13: note: declared here
repack.c:744:3: error: too few arguments to function ‘RenameRelationInternal’
In file included from repack.c:22:0:
/usr/include/postgresql/9.3/server/commands/tablecmds.h:60:13: note: declared here
repack.c:754:3: error: too few arguments to function ‘RenameRelationInternal’
In file included from repack.c:22:0:
/usr/include/postgresql/9.3/server/commands/tablecmds.h:60:13: note: declared here
repack.c:756:3: error: too few arguments to function ‘RenameRelationInternal’
In file included from repack.c:22:0:
/usr/include/postgresql/9.3/server/commands/tablecmds.h:60:13: note: declared here
repack.c:761:3: error: too few arguments to function ‘RenameRelationInternal’
In file included from repack.c:22:0:
/usr/include/postgresql/9.3/server/commands/tablecmds.h:60:13: note: declared here
repack.c:763:3: error: too few arguments to function ‘RenameRelationInternal’
In file included from repack.c:22:0:
/usr/include/postgresql/9.3/server/commands/tablecmds.h:60:13: note: declared here
repack.c:768:3: error: too few arguments to function ‘RenameRelationInternal’
In file included from repack.c:22:0:
/usr/include/postgresql/9.3/server/commands/tablecmds.h:60:13: note: declared here
repack.c:770:3: error: too few arguments to function ‘RenameRelationInternal’
In file included from repack.c:22:0:
/usr/include/postgresql/9.3/server/commands/tablecmds.h:60:13: note: declared here
make[1]: *** [repack.o] Error 1
make[1]: Leaving directory `/home/pfote/src/pg_repack-1.1.8/lib'
make: *** [all] Error 2

OS is Debian Whezzy 7.2

pg_repack and FK locks

This is basically an information request.

Does pg_repack lock all tables with foriegn keys referencing the table being repacked, during the last phase of repacking? It seems it must, but I can't find that in the code.

Please, help to build pg_repack on Gentoo

Hi!
I have installed Postgres 9.4.5 and 9.5.0.
pg_repack from master is failed to build with this error:
/usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lpgcommon
/usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lpgport
What info i need to provide to help you debug this problem?

lib makefile error

building 1.1.8 on amazon linux for community postgres 8.4

This in the lib/Makefile:

echo "BEGIN;\n" > $@;

resulted in a literal \n rather than a newline in the output file, causing an error. Similarly with COMMIT. At the very least it's not portable.

ERROR: cache lookup failed for opclass 0, with DESC index

Per report this morning from wannado on #postgresql, a pg_repack of the "contacts" table from this testcase:
https://gist.github.com/4240890

fails with:
ERROR: cache lookup failed for opclass 0

The error seems to be from the repack_get_index_keys() library function, which is called by the repack.tables view. The following query will reproduce the failure:

 SELECT
    repack.get_index_keys(ck.indexrelid, r.oid) AS ckey
   FROM pg_class r
   LEFT JOIN pg_class t ON r.reltoastrelid = t.oid
   LEFT JOIN repack.primary_keys pk ON r.oid = pk.indrelid
   LEFT JOIN ( SELECT cki.indexrelid, cki.indrelid, cki.indnatts, 
    cki.indisunique, cki.indisprimary, cki.indisexclusion, cki.indimmediate, 
    cki.indisclustered, cki.indisvalid, cki.indcheckxmin, cki.indisready, 
    cki.indislive, cki.indkey, cki.indcollation, cki.indclass, cki.indoption, 
    cki.indexprs, cki.indpred
   FROM pg_index cki, pg_class ckt
  WHERE cki.indisvalid AND cki.indexrelid = ckt.oid AND cki.indisclustered AND ckt.relam = 403::oid) ck ON r.oid = ck.indrelid
   LEFT JOIN pg_namespace n ON n.oid = r.relnamespace
   LEFT JOIN pg_tablespace s ON s.oid = r.reltablespace
  WHERE r.relname = 'contacts' AND r.relkind = 'r'::"char" AND (n.nspname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND n.nspname !~~ 'pg\_temp\_%'::text;

Errors when doing make on debian 7

We are migrating from postgres 9.1 to 9.3 & I've decided to install pg_repack
So I've downloaded, unpacked re_pack v1.3.3
Set the pg_config of PostgreSQL 9.3 in the PATH, so that typing pg_config gives me:
pg_config is /usr/lib/postgresql/9.3/bin/pg_config
But when I'm doing make, I receive:
Entering directory `/root/pg_repack-1.3.3/lib'
gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -I/usr/include/mit-krb5 -fPIC -pie -DLINUX_OOM_SCORE_ADJ=0 -fno-omit-frame-pointer -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -fpic -shared -Wl,--version-script=exports.list -o pg_repack.so repack.o pgut/pgut-be.o pgut/pgut-spi.o -L/usr/lib/x86_64-linux-gnu -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -L/usr/lib/mit-krb5 -L/usr/lib/x86_64-linux-gnu/mit-krb5 -L/usr/lib -Wl,--as-needed
/usr/bin/ld:exports.list:2: syntax error in VERSION script
collect2: error: ld returned 1 exit status

When I'm trying :
make PG_CONGIG=/usr/lib/postgresql/9.3/bin/pg_config --debug=v
I get:
/usr/include/postgresql/internal/pqexpbuffer.h:149:13: error: old-style parameter declarations in prototyped function definition
pg_repack.c:2002:1: error: expected '{' at end of input
make[1]: *** [pg_repack.o] Error 1
make[1]: Leaving directory `/root/pg_repack-1.3.1/bin'
make: *** [all] Error 2
I would be very thankful for help.

compiling pg_repack on Ubuntu 12.04 with apt.postgresql.org packages [SOLVED]

Posting this issue here just in case anyone else runs into it.

The problem:
Ubuntu 12.04
PostgreSQL 9.3 installed from apt.postgresql.org packages.

root@dev-postgres:/var/lib/postgresql/pg_repack# make
make[1]: Entering directory `/var/lib/postgresql/pg_repack/bin'
gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -I/usr/include/mit-krb5 -fPIC -pie -DLINUX_OOM_SCORE_ADJ=0 -fno-omit-frame-pointer -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g pg_repack.o pgut/pgut.o pgut/pgut-fe.o -L/usr/lib/x86_64-linux-gnu -lpq -L/usr/lib/x86_64-linux-gnu -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -L/usr/lib/mit-krb5 -L/usr/lib/x86_64-linux-gnu/mit-krb5 -L/usr/lib/x86_64-linux-gnu -Wl,--as-needed -lpgport -lpgcommon -lssl -lcrypto -lkrb5 -lcom_err -lgssapi_krb5 -lz -ledit -lcrypt -ldl -lm -o pg_repack
/usr/bin/ld: cannot find -ledit
collect2: ld returned 1 exit status
make[1]: *** [pg_repack] Error 1

The solution:

Install "libedit-dev" from the Ubuntu Repositories.

Reason:

pg_repack gets a list of gcc linking flags from the package libpq-dev. That includes libedit, but libedit-dev is not marked as a dependancy of libpq-dev, so it's not installed.

Underlying issue will be raised with apt.postgresql.org.

pgxn installation fails on debian 7.2

See stacktrace below:

pgxn info pg_repack

ERROR: unexpected error: ValueError - bad version number: '1.1.8-beta2'
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pgxnclient/cli.py", line 59, in script
main(args)
File "/usr/lib/python2.7/dist-packages/pgxnclient/cli.py", line 31, in main
run_command(opt, parser)
File "/usr/lib/python2.7/dist-packages/pgxnclient/commands/init.py", line 92, in run_command
return opts.cmd(opts, parser=parser).run()
File "/usr/lib/python2.7/dist-packages/pgxnclient/commands/info.py", line 149, in run
getattr(self, 'print_' + self.opts.what)(spec)
File "/usr/lib/python2.7/dist-packages/pgxnclient/commands/info.py", line 163, in print_details
ver = self.get_best_version(data, spec, quiet=True)
File "/usr/lib/python2.7/dist-packages/pgxnclient/commands/init.py", line 301, in get_best_version
vs = filter(spec.accepted, [SemVer(r['version']) for r in d])
File "/usr/lib/python2.7/dist-packages/pgxnclient/utils/semver.py", line 34, in new
self.tuple = SemVer.parse(value)
File "/usr/lib/python2.7/dist-packages/pgxnclient/utils/semver.py", line 100, in parse
raise ValueError(_("bad version number: '%s'") % s)
ValueError: bad version number: '1.1.8-beta2'

storage parameter on TOAST table gets lost

hi.

when using pg_repack/pg_reorg (same result) i recognized a missing storage parameter on my TOAST table after reorganization.

the table had set toast.autovacuum_vacuum_scale_factor to 0.1 (via ALTER TABLE mytable SET (toast.autovacuum_vacuum_scale_factor=0.1); )
when running pg_reorg/pg_repack on such table, the storage parameter for the TOAST table was gone.

used command was: pg_repack -n -e -U postgres -d playground -t mytable

server-version: PostgreSQL 9.1.6
pg_repack version 1.1.8

master currently broken

Some of the last commits, I think f6ca290, has broken master. Running the test suite from the current HEAD (at 6fc41e9) reports random errors such as:

ERROR:  invalid byte sequence for encoding "UTF8": 0xc0 0xb0
STATEMENT:  SELECT repack.array_accum(l.virtualtransaction)   FROM pg_locks AS l   LEFT JOIN pg_stat_activity AS a     ON l.pid = a.pid   WHERE l.locktype = 'virtualxid'   AND l.pid NOT IN (pg_backend_pid(), $1)   AND (l.virtualxid, l.virtualtransaction) <> ('1/1', '-1/0')   AND (a.application_name IS NULL OR a.application_name <> $2)
ERROR:  invalid byte sequence for encoding "UTF8": 0x90
STATEMENT:  SELECT repack.array_accum(l.virtualtransaction)   FROM pg_locks AS l   LEFT JOIN pg_stat_activity AS a     ON l.pid = a.pid   WHERE l.locktype = 'virtualxid'   AND l.pid NOT IN (pg_backend_pid(), $1)   AND (l.virtualxid, l.virtualtransaction) <> ('1/1', '-1/0')   AND (a.application_name IS NULL OR a.application_name <> $2)
ERROR:  invalid byte sequence for encoding "UTF8": 0xa0
STATEMENT:  SELECT repack.array_accum(l.virtualtransaction)   FROM pg_locks AS l   LEFT JOIN pg_stat_activity AS a     ON l.pid = a.pid   WHERE l.locktype = 'virtualxid'   AND l.pid NOT IN (pg_backend_pid(), $1)   AND (l.virtualxid, l.virtualtransaction) <> ('1/1', '-1/0')   AND (a.application_name IS NULL OR a.application_name <> $2)
ERROR:  invalid input syntax for integer:9"
STATEMENT:  SELECT repack.array_accum(l.virtualtransaction)   FROM pg_locks AS l   LEFT JOIN pg_stat_activity AS a     ON l.pid = a.pid   WHERE l.locktype = 'virtualxid'   AND l.pid NOT IN (pg_backend_pid(), $1)   AND (l.virtualxid, l.virtualtransaction) <> ('1/1', '-1/0')   AND (a.application_name IS NULL OR a.application_name <> $2)
ERROR:  invalid input syntax for integer: @3"
STATEMENT:  SELECT repack.array_accum(l.virtualtransaction)   FROM pg_locks AS l   LEFT JOIN pg_stat_activity AS a     ON l.pid = a.pid   WHERE l.locktype = 'virtualxid'   AND l.pid NOT IN (pg_backend_pid(), $1)   AND (l.virtualxid, l.virtualtransaction) <> ('1/1', '-1/0')   AND (a.application_name IS NULL OR a.application_name <> $2)

Smells like pointers...

Running on PG 9.2.1, Ubuntu 32 bits.

@schmiddy do you want me to try and debug this? I assume on your setup you haven't found the issue.

make fails in OS X 10.9.2 and ubuntu

I have installed PostgreSQL.app and was attempting to build pg_repack but ran into this error:

gcc -mmacosx-version-min=10.7 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -I/Applications/Postgres.app/Contents/Versions/9.3/include -DREPACK_VERSION=1.2.0-beta1 -I. -I. -I/Applications/Postgres.app/Contents/Versions/9.3/include/postgresql/server -I/Applications/Postgres.app/Contents/Versions/9.3/include/postgresql/internal -I/Applications/Postgres.app/Contents/Versions/9.3/include/libxml2 -I/Applications/Postgres.app/Contents/Versions/9.3/include -c -o pg_repack.o pg_repack.c
gcc -mmacosx-version-min=10.7 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -I/Applications/Postgres.app/Contents/Versions/9.3/include -DREPACK_VERSION=1.2.0-beta1 -I. -I. -I/Applications/Postgres.app/Contents/Versions/9.3/include/postgresql/server -I/Applications/Postgres.app/Contents/Versions/9.3/include/postgresql/internal -I/Applications/Postgres.app/Contents/Versions/9.3/include/libxml2 -I/Applications/Postgres.app/Contents/Versions/9.3/include -c -o pgut/pgut.o pgut/pgut.c
gcc -mmacosx-version-min=10.7 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -I/Applications/Postgres.app/Contents/Versions/9.3/include -DREPACK_VERSION=1.2.0-beta1 -I. -I. -I/Applications/Postgres.app/Contents/Versions/9.3/include/postgresql/server -I/Applications/Postgres.app/Contents/Versions/9.3/include/postgresql/internal -I/Applications/Postgres.app/Contents/Versions/9.3/include/libxml2 -I/Applications/Postgres.app/Contents/Versions/9.3/include -c -o pgut/pgut-fe.o pgut/pgut-fe.c
gcc -mmacosx-version-min=10.7 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv pg_repack.o pgut/pgut.o pgut/pgut-fe.o -L/Applications/Postgres.app/Contents/Versions/9.3/lib -lpq -L/Applications/Postgres.app/Contents/Versions/9.3/lib -L/Applications/Postgres.app/Contents/Versions/9.3/lib -L/Applications/Postgres.app/Contents/Versions/9.3/lib -Wl,-dead_strip_dylibs -lpgport -lpgcommon -lssl -lcrypto -lgssapi_krb5 -lz -lreadline -lm -o pg_repack
ld: library not found for -lpgport
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [pg_repack] Error 1
make: *** [all] Error 2

Could somebody clarify what dependency needs to be met to be able to build this on OS X

Also, on ubuntu I get the following errors during make:

make[1]: Entering directory /root/pg_repack-1.2.0-beta1/bin' gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -fPIC -DLINUX_OOM_ADJ=0 -fPIC -DLINUX_OOM_ADJ=0 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g pg_repack.o pgut/pgut.o pgut/pgut-fe.o -L/opt/postgresql-9.1/lib -lpq -L/opt/postgresql-9.1/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed -Wl,--as-needed -L/usr/lib/x86_64-linux-gnu -Wl,--as-needed -Wl,-rpath,'/opt/postgresql-9.1/lib',--enable-new-dtags -lpgport -lssl -lcrypto -lkrb5 -lcom_err -lgssapi_krb5 -lz -ledit -lcrypt -ldl -lm -o pg_repack /usr/bin/ld: cannot find -lkrb5 /usr/bin/ld: cannot find -lcom_err /usr/bin/ld: cannot find -lgssapi_krb5 /usr/bin/ld: cannot find -ledit collect2: ld returned 1 exit status make[1]: *** [pg_repack] Error 1 make[1]: Leaving directory/root/pg_repack-1.2.0-beta1/bin'
make: *** [all] Error 2

What are the prerequisites for pg_repack?

PostgreSQL 9.5 support

Are there any plans to support PostgreSQL 9.5? With pg_repack 1.3.2 PostgreSQL crashes with:

2016-01-26 11:03:57 EET STATEMENT:  select repack.version(), repack.version_sql()
2016-01-26 11:03:57 EET LOG:  statement: select repack.version(), repack.version_sql()
2016-01-26 11:03:57 EET LOG:  duration: 11.572 ms
2016-01-26 11:03:57 EET LOG:  statement: SET statement_timeout = 0
2016-01-26 11:03:57 EET LOG:  duration: 0.072 ms
2016-01-26 11:03:57 EET LOG:  statement: SET search_path = pg_catalog, pg_temp, public
2016-01-26 11:03:57 EET LOG:  duration: 0.092 ms
2016-01-26 11:03:57 EET LOG:  statement: SET client_min_messages = warning
2016-01-26 11:03:57 EET LOG:  duration: 0.049 ms
2016-01-26 11:03:57 EET LOG:  duration: 3.240 ms  parse <unnamed>: SELECT t.*, coalesce(v.tablespace, t.tablespace_orig) as tablespace_dest FROM repack.tables t,  (VALUES (quote_ident($1::text))) as v (tablespace) WHERE pkid IS NOT NULL ORDER BY t.relname, t.schemaname
2016-01-26 11:03:57 EET LOG:  duration: 63.406 ms  bind <unnamed>: SELECT t.*, coalesce(v.tablespace, t.tablespace_orig) as tablespace_dest FROM repack.tables t,  (VALUES (quote_ident($1::text))) as v (tablespace) WHERE pkid IS NOT NULL ORDER BY t.relname, t.schemaname
2016-01-26 11:03:57 EET DETAIL:  parameters: $1 = NULL
2016-01-26 11:03:57 EET LOG:  execute <unnamed>: SELECT t.*, coalesce(v.tablespace, t.tablespace_orig) as tablespace_dest FROM repack.tables t,  (VALUES (quote_ident($1::text))) as v (tablespace) WHERE pkid IS NOT NULL ORDER BY t.relname, t.schemaname
2016-01-26 11:03:57 EET DETAIL:  parameters: $1 = NULL
2016-01-26 11:04:00 EET LOG:  server process (PID 11784) was terminated by signal 11: Segmentation fault
2016-01-26 11:04:00 EET DETAIL:  Failed process was running: SELECT t.*, coalesce(v.tablespace, t.tablespace_orig) as tablespace_dest FROM repack.tables t,  (VALUES (quote_ident($1::text))) as v (tablespace) WHERE pkid IS NOT NULL ORDER BY t.relname, t.schemaname
2016-01-26 11:04:00 EET LOG:  terminating any other active server processes
2016-01-26 11:04:00 EET WARNING:  terminating connection because of crash of another server process

client must_be_superuser() check

I think we should have the pg_repack client double check that it is indeed running as superuser. If you try to run pg_repack as an non-superuser, and the user has enough privileges in the database, you can wind up in a nasty state:

Here's a quick example. Set up a non-superuser and a table in some database where pg_repack is installed:

BEGIN;
  CREATE ROLE limited_user WITH LOGIN;
  GRANT CREATE, USAGE ON SCHEMA repack TO limited_user;
  GRANT SELECT ON repack.tables TO limited_user;

  CREATE TABLE repack_test(a int PRIMARY KEY);
  ALTER TABLE repack_test OWNER TO limited_user;
COMMIT;

and now try to run:

pg_repack -Ulimited_user --table=repack_test --no-order --echo testdb

and you'll get something like:

LOG:    (param:4) = DELETE FROM repack.log_199475 WHERE id <= $1
LOG:    (param:5) = 1000
ERROR: query failed: ERROR:  must be superuser to use repack_apply function
DETAIL: query was: SELECT repack.repack_apply($1, $2, $3, $4, $5, $6)
LOG: (query) ROLLBACK
LOG: (query) SELECT repack.repack_drop($1)
LOG:    (param:0) = 199475
ERROR: query failed: ERROR:  must be superuser to use repack_drop function
DETAIL: query was: SELECT repack.repack_drop($1)
!!!FATAL ERROR!!! Please refer to the manual.

Abort trap

leaving the z_repack_trigger hanging behind on the repack_test table.

Patch: https://gist.github.com/4173742

Table exclude option

It would be useful to have an option to exclude tables from repacking based on name/schema with regex.

repack_apply() as a callable function

For one reason or another (outside of the scope of this bug report), I had to ctrl+c a pg_repack that was in progress. This left the trigger in place and the repack table growing in size (worried about duplicate keys at the time).

Anyway, I now have a repack.log_ table that has ~1M rows in it and no easy way of applying those changes back to its original table. It'd be great if there was a function that an admin could call that would apply the changes. In situations like these, I'd take a big INSERT that takes a while over something fancy that tries to conform to the APPLY_COUNT #define specified in pg_repack.c.

Cannot build on Debian GNU/Linux 8.1 (jessie)

SOLVED:
Turns out this is due to have the incorrect versions of libpq5 and libpq-dev

Getting access to older versions:
https://wiki.postgresql.org/wiki/Apt/FAQ#I_want_libpq5_for_version_X.2C_but_there_is_only_version_Y_in_the_repository

Attempting to build on Jessie fails with a multitude of errors.

Distributor ID: Debian
Description: Debian GNU/Linux 8.1 (jessie)
Release: 8.1
Codename: jessie

Linux scale-01 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1+deb8u3 (2015-08-04) x86_64 GNU/Linux

Postgres packages from apt.postgresql.org

  • postgresql-9.4
  • postgresql-9.4-repmgr
  • postgresql-client-9.4
  • postgresql-client-common
  • postgresql-common
  • postgresql-contrib-9.4
  • postgresql-server-dev-9.4

gcc (Debian 4.9.2-10) 4.9.2

pgxnclient 1.2.1

Make errors follow:

make[1]: Entering directory '/home/scale/pg_repack-1.3.2/bin'
gcc -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 -I/usr/include/mit-krb5 -fPIC -pie -DLINUX_OOM_SCORE_ADJ=0 -fno-omit-frame-pointer -I/usr/include/postgresql -DREPACK_VERSION=1.3.2 -I. -I./ -I/usr/include/postgresql/9.4/server -I/usr/include/postgresql/internal -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2  -I/usr/include/tcl8.6  -c -o pg_repack.o pg_repack.c
In file included from pgut/pgut.h:22:0,
                 from pgut/pgut-fe.h:13,
                 from pg_repack.c:25:
/usr/include/postgresql/internal/pqexpbuffer.h:149:13: warning: no previous prototype for ‘printfPQExpBuffer’ [-Wmissing-prototypes]
... snip...<builtin>: recipe for target 'pg_repack.o' failed
make[1]: *** [pg_repack.o] Error 1
make[1]: Leaving directory '/home/scale/pg_repack-1.3.2/bin'
Makefile:34: recipe for target 'all' failed
make: *** [all] Error 2

common/fe_memutils.h: No such file or directory

I am trying to build pg_repack in ubuntu but get the following error

/usr/include/postgresql/postgres_fe.h:27:32: fatal error: common/fe_memutils.h: No such file or directory

I am on Ubuntu 13.04 and have the following packages installed:

  • postgresql-server-9.2
  • postgresql-server-dev-9.2
  • postgresql-contrib-9.2
  • postgresql-client-9.2
  • postgresql-common

Add (preliminary) support for PG 9.4

From Thom Brown, after releasing 1.2.0-beta1:

Just tried this out on 9.4 and I get the following error:

psql (9.4devel)
Type "help" for help.

pgbench=# create extension pg_repack;
ERROR:  column "reltoastidxid" does not exist at character 5461
STATEMENT:  create extension pg_repack;
ERROR:  column "reltoastidxid" does not exist

This is due to the column being removed from pg_class as toast indexes
will now be treated like regular indexes.  Could you look at adding
support for this change?

lock_exclusive race condition

Hello,

I'm having some problems with repack on a database/table that is really, really busy. From the looks of it, I think the problem is lock_exclusive called from repack_one_table. This repeatedly:

  1. Terminates all conflicting connections on the relation.
  2. Waits from 100-1000ms to get the access exclusive lock.

The problem for busy tables is new connections seem to manage to sneak in between steps 1 and 2. Is there any way to get around this race condition? Could you revoke connect access to everything before you terminate the conflicting connections?

Once the lock is obtained, the repack finishes almost immediately, but it's disrupting everything for the ~10 minutes it's repeatedly trying to get the lock.

Thanks,
Barry

Strategy for busy tables

Hey guys,

I've let pg_repack run on one of our busy tables. It's finished the rewriting of the table however the flushing from what I can see is falling behind way too far to catch up. If I understand how it works correctly:

SELECT max(id) FROM repack.log_ is going up by ~ 1000 second while the min(id) is only climbing every 2-15 seconds when the repack.repack_apply operations finish.

Seem to be heading for problems here.

pg_advisory_lock (1,2) too small to handle oid's bigger than 2GB

Hello,
I have a database who's table oid's exceed the two gigabyte boundary. I therefore receive this error when I attempt pg_repack on any of these tables:

pg_repack -U postgres mavmail -t mailer_admin -h prod-legacy-psql.server.int
INFO: repacking table "mailer_admin"
ERROR: query failed: ERROR: value "3048471620" is out of range for type integer
DETAIL: query was: SELECT pg_try_advisory_lock($1, $2)

Thank you
Mark Steben
Database Administrator
Dominion Dealer Solutions
tel (413-327-3045)

Ignore (auto)vacuums in SQL_XID_SNAPSHOT check

One frustration I've encountered while running pg_repack in a busy production database is that concurrent autovacuums of other tables can show up in the SQL_XID_ALIVE query, which will think it needs to wait potentially many hours for the autovacuum to finish.

I believe it should be safe for us to simply ignore VACUUMs and autovacuums of other tables in the SQL_XID_SNAPSHOT query.

Table with unique index

pg_repack sometimes can't repack relatively busy table with unique index

ERROR: query failed: ERROR:  duplicate key value violates unique constraint "index_287502"
DETAIL:  Key (group_id, hash)=(1591954043305993739, 5338517406217073467) already exists.
CONTEXT:  SQL statement "INSERT INTO repack.table_17593 VALUES ($1.*)"
DETAIL: query was: SELECT repack.repack_apply($1, $2, $3, $4, $5, $6)

What is the right strategy in such situation? Just re-run pg_repack?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.