Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash while using REINDEX TABLE CONCURRENTLY #3123

Merged
merged 1 commit into from Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -10,6 +10,7 @@ accidentally triggering the load of a previous DB version.**
* #3101 Use commit date in get_git_commit()
* #3104 Fix use after free in add_reorder_policy
* #3106 Fix use after free in chunk_api_get_chunk_stats
* #3123 Fix crash while using REINDEX TABLE CONCURRENTLY

## 2.2.0 (2021-04-13)

Expand Down
7 changes: 6 additions & 1 deletion src/process_utility.c
Expand Up @@ -1478,13 +1478,18 @@ process_reindex(ProcessUtilityArgs *args)
{
PreventCommandDuringRecovery("REINDEX");
ts_hypertable_permissions_check_by_id(ht->fd.id);

#if PG12_GE
if (stmt->concurrent)
ereport(ERROR,
(errmsg("concurrent index creation on hypertables is not supported")));
#endif
if (foreach_chunk(ht, reindex_chunk, args) >= 0)
result = DDL_DONE;

add_hypertable_to_process_args(args, ht);
}
break;

case REINDEX_OBJECT_INDEX:
ht = ts_hypertable_cache_get_entry(hcache,
IndexGetRelation(relid, true),
Expand Down
3 changes: 3 additions & 0 deletions test/expected/index.out → test/expected/index-11.out
Expand Up @@ -595,6 +595,9 @@ INFO: index "_hyper_12_15_chunk_reindex_test_time_unique_idx" was reindexed
INFO: index "16_7_reindex_test_pkey" was reindexed
INFO: index "_hyper_12_16_chunk_reindex_test_time_unique_idx" was reindexed
\set ON_ERROR_STOP 0
-- REINDEX TABLE CONCURRENTLY is not supported on PG11 (but blocked on PG12+)
REINDEX TABLE CONCURRENTLY reindex_test;
ERROR: syntax error at or near "CONCURRENTLY" at character 15
-- this one currently doesn't recurse to chunks and instead gives an
-- error
REINDEX (VERBOSE) INDEX reindex_test_time_unique_idx;
Expand Down
727 changes: 727 additions & 0 deletions test/expected/index-12.out

Large diffs are not rendered by default.

727 changes: 727 additions & 0 deletions test/expected/index-13.out

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions test/sql/CMakeLists.txt
Expand Up @@ -20,7 +20,6 @@ set(TEST_FILES
grant_hypertable.sql
hash.sql
histogram_test.sql
index.sql
insert_many.sql
insert_single.sql
join.sql
Expand Down Expand Up @@ -66,6 +65,7 @@ set(TEST_TEMPLATES
sort_optimization.sql.in
sql_query.sql.in
update.sql.in
index.sql.in
)

# tests that fail or are unreliable when run in parallel
Expand All @@ -74,8 +74,11 @@ set(SOLO_TESTS
alter
alternate_users
bgw_launcher
chunk_utils.sql
index
chunk_utils
index-11
gayyappan marked this conversation as resolved.
Show resolved Hide resolved
index-12
index-13
loader
loader
net
pg_dump_unprivileged
Expand Down
4 changes: 4 additions & 0 deletions test/sql/index.sql → test/sql/index.sql.in
Expand Up @@ -280,6 +280,10 @@ SELECT * FROM test.show_subtables('reindex_test');
REINDEX (VERBOSE) TABLE reindex_test;

\set ON_ERROR_STOP 0

-- REINDEX TABLE CONCURRENTLY is not supported on PG11 (but blocked on PG12+)
REINDEX TABLE CONCURRENTLY reindex_test;

-- this one currently doesn't recurse to chunks and instead gives an
-- error
REINDEX (VERBOSE) INDEX reindex_test_time_unique_idx;
Expand Down