196 Commits

Author SHA1 Message Date
Daniele Varrazzo
fe519cf017 Dropped further libs not needed for build 2017-03-23 18:50:22 +00:00
Nathan Bossart
1f784089a6 Added regression testing for --no-superuser-check option. 2017-03-02 02:58:41 +00:00
bossartn
7471eeaa0c Merge branch 'master' into no_superuser_check 2017-03-01 08:34:29 -08:00
masahiko
b329f9e143 Merge pull request #108 from MasahikoSawada/dont_kill_backend
Introduce --no-kill-backend option.
2017-02-23 09:39:36 +09:00
Masahiko Sawada
9ef8f9f80b Improve error message more explicitely when time out.
This change distinguishes error message between failed to cancel
query due to time out and abandoning to cancel query due to timeout.
2017-02-22 06:03:54 +00:00
Masahiko Sawada
f6c1304c36 Change the option name to no-kill-backend.
For consistency with other slimilar option such as no-order,
no-analyze.
2017-02-22 03:49:04 +00:00
masahiko
5781aabb61 Merge pull request #107 from MasahikoSawada/change_to_after_trigger
Change trigger type to AFTER trigger.
2017-02-22 12:08:32 +09:00
Masahiko Sawada
e8d6b6b97f Change format identifier %lu in pgut.c file. 2017-02-21 12:23:18 +00:00
Nathan Bossart
168676b3b6 Introduce --no-superuser-check option.
The current client checks for superuser before attempting to
execute pg_repack commands. In Amazon RDS, customers are given
access to a psuedo-superuser role called rds_superuser, but they
are not given access to superuser. However, rds_superusers will
otherwise have the ability to execute pg_repack commands in RDS.

This change introduces the --no-superuser-check option in the
client code so that users can disable the client-side superuser
checks.
2017-02-15 03:15:03 +00:00
Masahiko Sawada
ff8cb96c74 Add white space to COUNT_COMPETING_LOCKS sql.
Pointed out by schmiddy.
2017-02-02 19:59:18 +09:00
Masahiko Sawada
34c6506f54 Introduce --dont-kill-backend option.
pg_repack needs to take an exclusive lock at the end of the
reorganization. If the lock cannot be taken after duration
--wait-timeout option specified and this option is true,
pg_repack gives up to repack a target table instead of
cancelling conflicting backend. False by default.
2017-01-24 14:47:00 +09:00
Masahiko Sawada
375f03c0c3 Change trigger name from a_repack_trigger to repack_trigger.
In AFTER trigger context, since triggered tuple is not changed by
any other triggers we can call it just repack_trigger.
2017-01-24 14:09:05 +09:00
Masahiko Sawada
d83ee3d6a0 Change trigger type to AFTER trigger.
During repacking table, if a transaction executes INSERT CONFLICT
ON UPDATE/DO NOTHING, because we define BEFORE trigger on target
table, the contents of operation log table becomes inconsistent
easliy. As a result, pg_reapck fails with a high probability.

To resolve this issue, this changes the trigger type from BEFORE
to AFTER. We define AFTER trigger that is the first of the AFTER
trigger to fire on the table.
2017-01-19 16:32:54 +09:00
Alexander Korotkov
8e50927946 Comment about VACUUM. 2016-07-03 22:42:17 +03:00
Alexander Korotkov
3b0ef954cf Fix. 2016-07-03 21:19:45 +03:00
Josh Kupershmidt
eb2e9c39fb Whitespace cleanup. 2016-05-07 09:24:05 -04:00
Edwina Lu
dcce8e43e9 grab exclusive lock before dropping table 2016-04-15 14:34:41 -07:00
bwtakacy
70eac9ee06 Change exit code for --help and --version.
Previously, it is 1 but the reason is not clear.
It seems to be a historical one because pg_reorg
has the same exit codes.
2015-11-26 21:51:09 +09:00
Josh Kupershmidt
facbcf90dd Wrong precedence for these chained less-than / greater-thans. 2015-07-24 07:27:30 -04:00
Josh Kupershmidt
70cc5769c9 Remember to free repacked_indexes. 2015-05-29 21:18:45 -04:00
Josh Kupershmidt
ffb1980ce4 Remove remaining pgut_strdup() uses in favor of num_buff,
so no more of those tiny leaks.
2015-05-27 21:33:34 -04:00
amit
775a97dbd9 Get rid of hacky usage of pgut_strdup() in utoa.
From inspecting the call sites of utoa, it appears that some of them
(especially the recent cleanup patch which added the strdup there) wanted
to prevent overwriting a local variable by repeated call (to utoa) using
the same variable as argument. This commit instead makes such call sites
strdup the variable itself before passing it to utoa. That seems cleaner
considering that it does not seem utoa's contract to do so (strdup its
parameter that is).
2015-05-27 11:11:15 +09:00
Josh Kupershmidt
d3a99db9f9 Merge branch 'kotsachin-master' 2015-05-25 17:26:31 -04:00
Josh Kupershmidt
8fc8b656a2 Some comments about our new atexit handling. 2015-05-25 16:56:44 -04:00
Josh Kupershmidt
b6b6a8bfb3 Merge branch 'master' of https://github.com/kotsachin/pg_repack into kotsachin-master 2015-05-25 10:59:32 -06:00
kotsachin
8a0466e4c2 Some improvements and fixes to previously submitted pull request for cleaning temporary objects 2015-05-25 18:14:47 +09:00
Josh Kupershmidt
39cc3b474d Use pgut_strdup() instead of strdup(). 2015-05-04 21:21:16 -04:00
Josh Kupershmidt
4e69428700 Merge branch 'master' of https://github.com/kotsachin/pg_repack into kotsachin-master 2015-05-01 15:30:34 -04:00
bwtakacy
6afbaaa012 Change log level as noted in documentation.
If there are two concurrent pg_repack commands are run on the same
table, the one starting later fails with error message:
Another pg_repack command may be running on the table. Please try again.
The document says this is shown as ERROR, but actualy is WARNING.
2015-04-27 15:48:38 +09:00
kotsachin
ad109edb5b This patch contains repack_cleanup_callback() which calls to repack_drop() for cleaning temporary objects. repack_cleanup_callback() will be pushed on stack using pgut_atexit_push() at beginning so that it will pop on abort or exit of program.
This patch includes one global counter (temp_obj_num) which counts number of temporary objects created by pg_repack. Correct order of deletion of temporary object as per count avoids unintentional error messages.
2015-04-17 13:07:01 +09:00
Daniele Varrazzo
564f061beb Use the right appendStringInfoVA interface
pgut version renamed to avoid confusion with the server version.

(I wonder why there is such a duplication of interfaces and
implementations there though...)
2015-03-10 11:48:16 +00:00
Josh Kupershmidt
de8853b241 Wordsmith error message when repack_one_database() fails. 2015-01-26 19:21:27 -05:00
bwtakacy
49e542a0b6 Improve error message when repack against non-existing table.
Previously, pg_repack shows "ERROR: ERROR: relation foo does not
exist" when specify non-existing table. Though the first ERROR
is from pg_repack and the second ERROR is from PostgreSQL server,
some users might think that pg_repack shows error level twice
wrongly.
2015-01-16 10:21:17 +09:00
Josh Kupershmidt
ef4dc5a1fb Tweak apply_log() loop so that we don't wait until getting
all the way down to 0 rows processed before performing the
table swap step.
2015-01-11 20:59:13 -05:00
Josh Kupershmidt
8f61e44efd Tweak logic for when to display:
"Waiting for %d transactions to finish. First PID: %s"

message. Display it on every loop through the SQL_XID_ALIVE check
(i.e. every second), instead of only when the number of transactions
we're waiting on changes -- previously, it was too easy for that
important message to get lost in other messages.

And don't display the message at all when running under pg_regress,
i.e. as part of `make installcheck`. We had been getting occasional
errors from pg_regress when autovacuum was running and that message
got logged.
2015-01-11 19:31:09 -05:00
Josh Kupershmidt
080ebd3ed6 Bump up Copyright notices for 2015 2015-01-11 19:01:37 -05:00
Andrew Dunstan
db4ec04cf2 Do get_indexdef calls while the table is already locked.
These calls can require an access share lock on the table, which might
conflict with an existing or later acquires lock. So perform these calls
while we already have an exclusive lock on the table. This unfortuantely
means that we ave to remove the constness of the table parameter to
repack_one_table, as it is not modifying the table object to set up the
indexes.
2014-12-30 16:48:06 -05:00
Andrew Dunstan
9f77a2fd03 Gather index info at the same time as table info, rather than later.
This helps avoid possible problems with later strong table locks.
2014-12-30 10:48:35 -05:00
Josh Kupershmidt
6d3c085b22 Fix up commit 4b3347, where I failed to notice that the initial
problem was really about the OID being interpreted as an integer
literal upon input, and overflowing its integer space before even making
it into pg_try_advisory_lock(). (We do still need to add -2147483648 to
make the result fit into an integer, as 4b3347 does.)

Hopefully fixes issue #30, for real this time.
2014-11-20 17:18:15 -05:00
Josh Kupershmidt
4b334745a3 Ensure that unsigned 4-byte OIDs are able to squeeze into the signed
4-byte int accepted by the two-argument form of pg_try_advisory_lock()
we are using.

Fixes #30. Thanks to Mark Steben and Greg Sabino Mullane for the report
and diagnosis.
2014-11-13 20:54:48 -05:00
Josh Kupershmidt
649e72c0a4 Add some ORDER BYs to queries fetching lists of tables/indexes
to be repacked, in order to ensure consistent installcheck results.
2014-05-26 20:57:28 -04:00
Josh Kupershmidt
f0cd787bf5 Merge in Pull Request #20 from Steeve Lennmark.
Adds support for repacking only the tables in a specified schema. This
doesn't support --only-indexes mode, but that seems alright for now.

Fix merge conflicts, and make a few tweaks along the way:
 * bump version to 1.3-dev0
 * add Beena to list of maintainers
 * documentation wordsmithing
 * fix up the INFO message printed for each index in --index or
   --only-indexes mode, so that it is only printed once per index, and
   prints the name of the original index, not that of the transient
   index_%u name.
2014-05-24 15:42:24 -04:00
schmiddy
4eb1cef99e Make the 'repacking index ...' message be displayed
for indexes-only repacks (not just when in dry-run mode).
2014-05-24 00:09:03 -04:00
Steeve Lennmark
f094795178 Clean up tests and fix regression
It was possible to specify both --schema and --table which probably
-should- be legal but would need some code to be rewritten. This patch
adds a check that both can't be specified and returns an error telling
the user to use schema.table notation instead. A regression test
checking this behaviour was added.
2014-01-31 08:22:12 +00:00
Steeve Lennmark
5affda20ea Move new log output to inside the dryrun block 2014-01-30 12:53:22 +00:00
Steeve Lennmark
f10a41c4e1 Add output explaining that repack won't be issued 2014-01-30 12:50:15 +00:00
Steeve Lennmark
bf277a4e5f Add support for dry run -N (--dryrun) 2014-01-24 15:27:42 +01:00
Steeve Lennmark
e16472419f Fix regression while refactoring patch 2014-01-22 14:55:07 +01:00
Steeve Lennmark
1a10df9049 Add support for repacking an entire schema
This adds the option -c (--schema).
2014-01-22 14:23:56 +01:00
FIRST man
7487a775d5 skip transactions and locks in other databases when checking pg_locks' entries
problem: in case there are open transactions on other databases then the
         one pg_repack is working on and pg_locks doesn't contain any
         information about the affected database oid of the locked relation
         (e.g. there is no locked relation, only an open transaction),
         pg_repack will wait for that connection to release the lock
         (even if the relation that gets reorganized is held in an
         different database).

solution: join pg_database (via pg_stat_activity's datid) and check
          if the connection (of the conflicted transaction) is established
          on a different database than the relation treated by pg_repack
          and skip them.
          furthermore don't exclude transactions from other databases when
          shared objects are locked.
2013-08-02 15:22:16 +02:00