resolve conflicts
This commit is contained in:
commit
4e90fe9b48
@ -2,19 +2,19 @@
|
||||
"name": "pg_repack",
|
||||
"abstract": "PostgreSQL module for data reorganization",
|
||||
"description": "Reorganize tables in PostgreSQL databases with minimal locks",
|
||||
"version": "1.3.4",
|
||||
"version": "1.4-dev0",
|
||||
"maintainer": [
|
||||
"Josh Kupershmidt <schmiddy@gmail.com>",
|
||||
"Daniele Varrazzo <daniele.varrazzo@gmail.com>",
|
||||
"Beena Emerson <memissemerson@gmail.com>"
|
||||
],
|
||||
"tags": [ "bloat", "maintenance", "vacuum", "cluster" ],
|
||||
"release_status": "stable",
|
||||
"release_status": "testing",
|
||||
"license": "bsd",
|
||||
"provides": {
|
||||
"pg_repack": {
|
||||
"file": "lib/pg_repack.sql",
|
||||
"version": "1.3.4",
|
||||
"version": "1.4-dev0",
|
||||
"abstract": "Reorganize tables in PostgreSQL databases with minimal locks"
|
||||
}
|
||||
},
|
||||
|
@ -33,6 +33,4 @@ include $(PGXS)
|
||||
# remove dependency on libxml2, libxslt, and libpam.
|
||||
# XXX: find a better way to make sure we are linking with libraries
|
||||
# from pg_config which we actually need.
|
||||
LIBS := $(filter-out -lxml2, $(LIBS))
|
||||
LIBS := $(filter-out -lxslt, $(LIBS))
|
||||
LIBS := $(filter-out -lpam, $(LIBS))
|
||||
LIBS := $(filter-out -ledit -lgssapi_krb5 -lpam -lselinux -lxml2 -lxslt, $(LIBS))
|
||||
|
@ -252,6 +252,7 @@ static bool dryrun = false;
|
||||
static unsigned int temp_obj_num = 0; /* temporary objects counter */
|
||||
static bool no_kill_backend = false; /* abandon when timed-out */
|
||||
static bool no_superuser_check = false;
|
||||
static SimpleStringList exclude_extension_list = {NULL, NULL}; /* don't repack tables of these extensions */
|
||||
|
||||
/* buffer should have at least 11 bytes */
|
||||
static char *
|
||||
@ -280,6 +281,7 @@ static pgut_option options[] =
|
||||
{ 'i', 'j', "jobs", &jobs },
|
||||
{ 'b', 'D', "no-kill-backend", &no_kill_backend },
|
||||
{ 'b', 'k', "no-superuser-check", &no_superuser_check },
|
||||
{ 'l', 'C', "exclude-extension", &exclude_extension_list },
|
||||
{ 0 },
|
||||
};
|
||||
|
||||
@ -314,10 +316,16 @@ main(int argc, char *argv[])
|
||||
else if (r_index.head && only_indexes)
|
||||
ereport(ERROR, (errcode(EINVAL),
|
||||
errmsg("cannot specify --index (-i) and --only-indexes (-x)")));
|
||||
else if (r_index.head && exclude_extension_list.head)
|
||||
ereport(ERROR, (errcode(EINVAL),
|
||||
errmsg("cannot specify --index (-i) and --exclude-extension (-C)")));
|
||||
else if (only_indexes && !(table_list.head || parent_table_list.head))
|
||||
ereport(ERROR, (errcode(EINVAL),
|
||||
errmsg("cannot repack all indexes of database, specify the table(s)"
|
||||
"via --table (-t) or --parent-table (-I)")));
|
||||
else if (only_indexes && exclude_extension_list.head)
|
||||
ereport(ERROR, (errcode(EINVAL),
|
||||
errmsg("cannot specify --only-indexes (-x) and --exclude-extension (-C)")));
|
||||
else if (alldb)
|
||||
ereport(ERROR, (errcode(EINVAL),
|
||||
errmsg("cannot repack specific index(es) in all databases")));
|
||||
@ -347,6 +355,11 @@ main(int argc, char *argv[])
|
||||
(errcode(EINVAL),
|
||||
errmsg("cannot repack specific table(s) in schema, use schema.table notation instead")));
|
||||
|
||||
if (exclude_extension_list.head && table_list.head)
|
||||
ereport(ERROR,
|
||||
(errcode(EINVAL),
|
||||
errmsg("cannot specify --table (-t) and --exclude-extension (-C)")));
|
||||
|
||||
if (noorder)
|
||||
orderby = "";
|
||||
|
||||
@ -608,17 +621,22 @@ repack_one_database(const char *orderby, char *errbuf, size_t errsize)
|
||||
SimpleStringListCell *cell;
|
||||
const char **params = NULL;
|
||||
int iparam = 0;
|
||||
size_t num_parent_tables;
|
||||
size_t num_tables;
|
||||
size_t num_schemas;
|
||||
size_t num_params;
|
||||
size_t num_parent_tables,
|
||||
num_tables,
|
||||
num_schemas,
|
||||
num_params,
|
||||
num_excluded_extensions;
|
||||
|
||||
num_parent_tables = simple_string_list_size(parent_table_list);
|
||||
num_tables = simple_string_list_size(table_list);
|
||||
num_schemas = simple_string_list_size(schema_list);
|
||||
num_excluded_extensions = simple_string_list_size(exclude_extension_list);
|
||||
|
||||
/* 1st param is the user-specified tablespace */
|
||||
num_params = num_parent_tables + num_tables + num_schemas + 1;
|
||||
num_params = num_excluded_extensions +
|
||||
num_parent_tables +
|
||||
num_tables +
|
||||
num_schemas + 1;
|
||||
params = pgut_malloc(num_params * sizeof(char *));
|
||||
|
||||
initStringInfo(&sql);
|
||||
@ -695,6 +713,29 @@ repack_one_database(const char *orderby, char *errbuf, size_t errsize)
|
||||
{
|
||||
appendStringInfoString(&sql, "pkid IS NOT NULL");
|
||||
}
|
||||
|
||||
/* Exclude tables which belong to extensions */
|
||||
if (exclude_extension_list.head)
|
||||
{
|
||||
appendStringInfoString(&sql, " AND t.relid NOT IN"
|
||||
" (SELECT d.objid::regclass"
|
||||
" FROM pg_depend d JOIN pg_extension e"
|
||||
" ON d.refobjid = e.oid"
|
||||
" WHERE d.classid = 'pg_class'::regclass AND (");
|
||||
|
||||
/* List all excluded extensions */
|
||||
for (cell = exclude_extension_list.head; cell; cell = cell->next)
|
||||
{
|
||||
appendStringInfo(&sql, "e.extname = $%d", iparam + 1);
|
||||
params[iparam++] = cell->val;
|
||||
|
||||
appendStringInfoString(&sql, cell->next ? " OR " : ")");
|
||||
}
|
||||
|
||||
/* Close subquery */
|
||||
appendStringInfoString(&sql, ")");
|
||||
}
|
||||
|
||||
/* Ensure the regression tests get a consistent ordering of tables */
|
||||
appendStringInfoString(&sql, " ORDER BY t.relname, t.schemaname");
|
||||
|
||||
@ -2165,4 +2206,5 @@ pgut_help(bool details)
|
||||
printf(" -D, --no-kill-backend don't kill other backends when timed out\n");
|
||||
printf(" -Z, --no-analyze don't analyze at end\n");
|
||||
printf(" -k, --no-superuser-check skip superuser checks in client\n");
|
||||
printf(" -C, --exclude-extension don't repack tables which belong to specific extension\n");
|
||||
}
|
||||
|
@ -131,6 +131,7 @@ Options:
|
||||
-D, --no-kill-backend don't kill other backends when timed out
|
||||
-Z, --no-analyze don't analyze at end
|
||||
-k, --no-superuser-check skip superuser checks in client
|
||||
-C, --exclude-extension don't repack tables which belong to specific extension
|
||||
|
||||
Connection options:
|
||||
-d, --dbname=DBNAME database to connect
|
||||
@ -227,6 +228,9 @@ Reorg Options
|
||||
Skip the superuser checks in the client. This setting is useful for using
|
||||
pg_repack on platforms that support running it as non-superusers.
|
||||
|
||||
``-C``, ``--exclude-extension``
|
||||
Skip tables that belong to the specified extension(s). Some extensions
|
||||
may heavily depend on such tables at planning time etc.
|
||||
|
||||
Connection Options
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
@ -387,21 +391,19 @@ WARNING: the table "tbl" already has a trigger called repack_trigger
|
||||
You can remove all the temporary objects by dropping and re-creating the
|
||||
extension: see the installation_ section for the details.
|
||||
|
||||
ERROR: Another pg_repack command may be running on the table. Please try again
|
||||
later.
|
||||
|
||||
There is a chance of deadlock when two concurrent pg_repack commands are run
|
||||
on the same table. So, try to run the command after some time.
|
||||
ERROR: Another pg_repack command may be running on the table. Please try again later.
|
||||
There is a chance of deadlock when two concurrent pg_repack commands are
|
||||
run on the same table. So, try to run the command after some time.
|
||||
|
||||
WARNING: Cannot create index "schema"."index_xxxxx", already exists
|
||||
DETAIL: An invalid index may have been left behind by a previous pg_repack on
|
||||
the table which was interrupted. Please use DROP INDEX "schema"."index_xxxxx"
|
||||
to remove this index and try again.
|
||||
DETAIL: An invalid index may have been left behind by a previous pg_repack
|
||||
on the table which was interrupted. Please use DROP INDEX
|
||||
"schema"."index_xxxxx" to remove this index and try again.
|
||||
|
||||
A temporary index apparently created by pg_repack has been left behind, and
|
||||
we do not want to risk dropping this index ourselves. If the index was in
|
||||
fact created by an old pg_repack job which didn't get cleaned up, you
|
||||
should just use DROP INDEX and try the repack command again.
|
||||
A temporary index apparently created by pg_repack has been left behind, and
|
||||
we do not want to risk dropping this index ourselves. If the index was in
|
||||
fact created by an old pg_repack job which didn't get cleaned up, you
|
||||
should just use DROP INDEX and try the repack command again.
|
||||
|
||||
|
||||
Restrictions
|
||||
@ -473,10 +475,19 @@ Creating indexes concurrently comes with a few caveats, please see `the document
|
||||
Releases
|
||||
--------
|
||||
|
||||
* pg_repack 1.4
|
||||
|
||||
* added support for PostgreSQL 9.6
|
||||
* use ``AFTER`` trigger to solve concurrency problems with ``INSERT
|
||||
CONFLICT`` (issue #106)
|
||||
* added ``--no-kill-backend`` option (issue #108)
|
||||
* added ``--no-superuser-check`` option (issue #114)
|
||||
* added ``--exclude-extension`` option (#97)
|
||||
|
||||
* pg_repack 1.3.4
|
||||
|
||||
* grab exclusive lock before dropping original table (#81)
|
||||
* do not attempt to repack unlogged tables (#71)
|
||||
* grab exclusive lock before dropping original table (issue #81)
|
||||
* do not attempt to repack unlogged tables (issue #71)
|
||||
|
||||
* pg_repack 1.3.3
|
||||
|
||||
|
@ -208,6 +208,7 @@ pg_repackもしくはpg_reorgの古いバージョンからのアップグレー
|
||||
-T, --wait-timeout=SECS timeout to cancel other backends on conflict
|
||||
-D, --no-kill-backend don't kill other backends when timed out
|
||||
-Z, --no-analyze don't analyze at end
|
||||
-k, --no-superuser-check skip superuser checks in client
|
||||
|
||||
Connection options:
|
||||
-d, --dbname=DBNAME database to connect
|
||||
@ -247,6 +248,7 @@ OPTIONには以下のものが指定できます。
|
||||
-T, --wait-timeout=SECS ロック競合している他のトランザクションをキャンセルするまで待機する時間を指定します
|
||||
-D, --no-kill-backend タイムアウト時に他のバックエンドをキャンセルしません
|
||||
-Z, --no-analyze 再編成後にANALYZEを行いません
|
||||
-k, --no-superuser-check 接続ユーザがスーパーユーザかどうかのチェックを行いません
|
||||
|
||||
接続オプション:
|
||||
-d, --dbname=DBNAME 接続する対象のデータベースを指定します
|
||||
@ -361,14 +363,15 @@ OPTIONには以下のものが指定できます。
|
||||
The default is 60 seconds.
|
||||
|
||||
``-T SECS``, ``--wait-timeout=SECS``
|
||||
pg_repackは再編成の完了直前に排他ロックを利用します。このオプションは、このロック取得時に何秒間pg_repackが取得を待機するかを指定します。指定した時間経ってもロックが取得できないかつ、`no-kill-backend`オプションが指定されていない場合、pg_repackは競合するクエリを強制的にキャンセルさせます。PostgreSQL 8.4以上のバージョンを利用している場合、指定した時間の2倍以上経ってもロックが取得できない場合、pg_repackは競合するクエリを実行しているPostgreSQLバックエンドプロセスをpg_terminate_backend()関数により強制的に停止させます。このオプションのデフォルトは60秒です。
|
||||
pg_repackは再編成の完了直前に排他ロックを利用します。このオプションは、このロック取得時に何秒間pg_repackが取得を待機するかを指定します。指定した時間経ってもロックが取得できないかつ、``no-kill-backend``\オプションが指定されていない場合、pg_repackは競合するクエリを強制的にキャンセルさせます。PostgreSQL 8.4以上のバージョンを利用している場合、指定した時間の2倍以上経ってもロックが取得できない場合、pg_repackは競合するクエリを実行しているPostgreSQLバックエンドプロセスをpg_terminate_backend()関数により強制的に停止させます。このオプションのデフォルトは60秒です。
|
||||
|
||||
.. ``-D``, ``--no-kill-backend``
|
||||
Skip to repack table if the lock cannot be taken for duration specified
|
||||
``--wait-timeout``, instead of cancelling conflicting queries. The default
|
||||
is false.
|
||||
|
||||
``-D``, ``--no-kill-backend``
|
||||
``--wait-timeout``オプションで指定された時間が経過してもロックが取得できない場合、競合するクエリをキャンセルする代わりに対象テーブルの再編成をスキップします。
|
||||
``--wait-timeout``\オプションで指定された時間が経過してもロックが取得できない場合、競合するクエリをキャンセルする代わりに対象テーブルの再編成をスキップします。
|
||||
|
||||
.. ``-Z``, ``--no-analyze``
|
||||
Disable ANALYZE after a full-table reorganization. If not specified, run
|
||||
@ -377,6 +380,13 @@ OPTIONには以下のものが指定できます。
|
||||
``-Z``, ``--no-analyze``
|
||||
再編成終了後にANALYZEを行うことを無効にします。デフォルトでは再編成完了後に統計情報を更新するためANALYZEを実行します。
|
||||
|
||||
.. ``-k``, ``--no-superuser-check``
|
||||
Skip the superuser checks in the client. This setting is useful for using
|
||||
pg_repack on platforms that support running it as non-superusers.
|
||||
|
||||
``-k``, ``--no-superuser-check``
|
||||
接続ユーザがスーパーユーザかどうかのチェックを行いません。これは、非スーパーユーザのみが利用できる環境でpg_repackを使用するときに有用です。
|
||||
|
||||
.. Connection Options
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
Options to connect to servers. You cannot use ``--all`` and ``--dbname`` or
|
||||
@ -846,6 +856,39 @@ ACCESS EXCLUSIVEロックを取得します。その他のステップでは、A
|
||||
リリースノート
|
||||
---------------
|
||||
|
||||
.. * pg_repack 1.3.4
|
||||
.. * grab exclusive lock before dropping original table (#81)
|
||||
.. * do not attempt to repack unlogged table (#71)
|
||||
|
||||
* pg_repack 1.3.4
|
||||
|
||||
* 元テーブルを削除する前に排他ロックを取得するようにしました(#81)
|
||||
* Unlogged Tableを再編成対象から外すようにしました (#71)
|
||||
|
||||
.. * pg_repack 1.3.3
|
||||
.. * Added support for PostgreSQL 9.5
|
||||
.. * Fixed possible deadlock when pg_repack command is interrupted (issue #55)
|
||||
.. * Fixed exit code for when pg_repack is invoked with ``--help`` and
|
||||
.. ``--version``
|
||||
.. * Added Japanese language user manual
|
||||
|
||||
* pg_repack 1.3.3
|
||||
|
||||
* PostgreSQL 9.5をサポートしました
|
||||
* pg_repackが中断されたときにデッドロックが発生する可能性を修正しました (issue #55)
|
||||
* ``--help`` または ``--version`` オプションを指定した実行したときの終了コードを修正しました
|
||||
* 日本語のユーザマニュアルを追加しました
|
||||
|
||||
.. * pg_repack 1.3.2
|
||||
.. * Fixed to clean up temporary objects when pg_repack command is interrupted.
|
||||
.. * Fixed possible crash when pg_repack shared library is loaded a alongside
|
||||
.. pg_statsinfo (issue #43)
|
||||
|
||||
* pg_repack 1.3.2
|
||||
|
||||
* pg_repackが中断されたときに一時オブジェクトを削除するようにしました
|
||||
* pg_statsinfoと同時にロードされている時にクラッシュする可能性を修正しました
|
||||
|
||||
.. * pg_repack 1.3.1
|
||||
.. * Added support for PostgreSQL 9.4.
|
||||
|
||||
|
@ -404,6 +404,26 @@ LINE 1: select repack.version(), repack.version_sql()
|
||||
^
|
||||
DROP ROLE IF EXISTS nosuper;
|
||||
--
|
||||
-- exclude extension check
|
||||
--
|
||||
CREATE SCHEMA exclude_extension_schema;
|
||||
CREATE TABLE exclude_extension_schema.tbl(val integer primary key);
|
||||
-- => ERROR
|
||||
\! pg_repack --dbname=contrib_regression --table=dummy_table --exclude-extension=dummy_extension
|
||||
ERROR: cannot specify --table (-t) and --exclude-extension (-C)
|
||||
-- => ERROR
|
||||
\! pg_repack --dbname=contrib_regression --table=dummy_table --exclude-extension=dummy_extension -x
|
||||
ERROR: cannot specify --only-indexes (-x) and --exclude-extension (-C)
|
||||
-- => ERROR
|
||||
\! pg_repack --dbname=contrib_regression --index=dummy_index --exclude-extension=dummy_extension
|
||||
ERROR: cannot specify --index (-i) and --exclude-extension (-C)
|
||||
-- => OK
|
||||
\! pg_repack --dbname=contrib_regression --schema=exclude_extension_schema --exclude-extension=dummy_extension
|
||||
INFO: repacking table "exclude_extension_schema.tbl"
|
||||
-- => OK
|
||||
\! pg_repack --dbname=contrib_regression --schema=exclude_extension_schema --exclude-extension=dummy_extension --exclude-extension=dummy_extension
|
||||
INFO: repacking table "exclude_extension_schema.tbl"
|
||||
--
|
||||
-- table inheritance check
|
||||
--
|
||||
CREATE TABLE parent_a(val integer primary key);
|
||||
|
@ -246,6 +246,22 @@ CREATE ROLE nosuper WITH LOGIN;
|
||||
\! pg_repack --dbname=contrib_regression --table=tbl_cluster --username=nosuper --no-superuser-check
|
||||
DROP ROLE IF EXISTS nosuper;
|
||||
|
||||
--
|
||||
-- exclude extension check
|
||||
--
|
||||
CREATE SCHEMA exclude_extension_schema;
|
||||
CREATE TABLE exclude_extension_schema.tbl(val integer primary key);
|
||||
-- => ERROR
|
||||
\! pg_repack --dbname=contrib_regression --table=dummy_table --exclude-extension=dummy_extension
|
||||
-- => ERROR
|
||||
\! pg_repack --dbname=contrib_regression --table=dummy_table --exclude-extension=dummy_extension -x
|
||||
-- => ERROR
|
||||
\! pg_repack --dbname=contrib_regression --index=dummy_index --exclude-extension=dummy_extension
|
||||
-- => OK
|
||||
\! pg_repack --dbname=contrib_regression --schema=exclude_extension_schema --exclude-extension=dummy_extension
|
||||
-- => OK
|
||||
\! pg_repack --dbname=contrib_regression --schema=exclude_extension_schema --exclude-extension=dummy_extension --exclude-extension=dummy_extension
|
||||
|
||||
--
|
||||
-- table inheritance check
|
||||
--
|
||||
@ -271,4 +287,3 @@ CREATE TABLE child_b_2(val integer primary key) INHERITS(parent_b);
|
||||
\! pg_repack --dbname=contrib_regression --table=parent_a --parent-table=parent_b --only-indexes
|
||||
-- => OK
|
||||
\! pg_repack --dbname=contrib_regression --parent-table=parent_a --parent-table=parent_b --only-indexes
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user