Skip to content

Commit

Permalink
[BACKPORT 2.4][#9550] ysql: output NOTICE when CREATE INDEX in txn block
Browse files Browse the repository at this point in the history
Summary:
There exists a DEBUG1 error message that indicates that the index is not
built concurrently when it is created in a transaction block.  To
increase visibility of this message, change it to NOTICE.  Also, reword
it better.

Original Commit: 3e5edfa

Original Differential Revision: https://phabricator.dev.yugabyte.com/D12447

Test Plan:
Jenkins: build platform: centos, compiler: clang, build type: debug, rebase: 2.4

    ./yb_build.sh --java-test TestPgRegressTable
    ./yb_build.sh --java-test TestPgRegressTypesUDT

Reviewers: mihnea

Reviewed By: mihnea

Subscribers: yql

Differential Revision: https://phabricator.dev.yugabyte.com/D12476
  • Loading branch information
jaki committed Aug 5, 2021
1 parent b40c9d3 commit eb59b23
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/postgres/src/backend/tcop/utility.c
Expand Up @@ -1377,11 +1377,14 @@ ProcessUtilitySlow(ParseState *pstate,
* build.
* TODO(jason): heed issue #6240.
*/
ereport(DEBUG1,
ereport(NOTICE,
(errmsg("making create index for table "
"\"%s\" in transaction block "
"nonconcurrent",
stmt->relation->relname)));
"\"%s\" nonconcurrent",
stmt->relation->relname),
errdetail("Create index in transaction"
" block cannot be concurrent."),
errhint("Consider running it outside of a"
" transaction block. See https://github.com/yugabyte/yugabyte-db/issues/6240.")));
stmt->concurrent = false;
}
else
Expand Down
6 changes: 6 additions & 0 deletions src/postgres/src/test/regress/expected/yb_create_table.out
Expand Up @@ -706,3 +706,9 @@ set yb_enable_create_with_table_oid=0;
create table with_table_oid_variable_false (a int) with (table_oid = 55555);
ERROR: Create table with oid is not allowed.
HINT: Try enabling the session variable yb_enable_create_with_table_oid.
RESET yb_enable_create_with_table_oid;
-- CREATE TABLE with implicit UNIQUE INDEX shouldn't spout a notice about it
-- being nonconcurrent.
BEGIN;
CREATE TABLE tab_with_unique (i int, UNIQUE (i));
COMMIT;
27 changes: 27 additions & 0 deletions src/postgres/src/test/regress/expected/yb_pg_create_index.out
Expand Up @@ -27,3 +27,30 @@ CREATE INDEX iix ON ihighway USING lsm (name text_ops);
ERROR: relation "ihighway" does not exist
CREATE INDEX six ON shighway USING lsm (name text_ops);
ERROR: relation "shighway" does not exist
--
-- Try some concurrent index builds
--
-- Unfortunately this only tests about half the code paths because there are
-- no concurrent updates happening to the table at the same time.
CREATE TABLE concur_heap (f1 text, f2 text);
-- empty table
CREATE INDEX CONCURRENTLY concur_index1 ON concur_heap(f2,f1);
ERROR: CREATE INDEX CONCURRENTLY not supported yet
LINE 1: CREATE INDEX CONCURRENTLY concur_index1 ON concur_heap(f2,f1...
^
HINT: Please report the issue on https://github.com/YugaByte/yugabyte-db/issues
-- You can't do a concurrent index build in a transaction
BEGIN;
CREATE INDEX CONCURRENTLY concur_index7 ON concur_heap(f1);
ERROR: CREATE INDEX CONCURRENTLY not supported yet
LINE 1: CREATE INDEX CONCURRENTLY concur_index7 ON concur_heap(f1);
^
HINT: Please report the issue on https://github.com/YugaByte/yugabyte-db/issues
COMMIT;
-- But you can do a regular index build in a transaction
BEGIN;
CREATE INDEX std_index on concur_heap(f2);
NOTICE: making create index for table "concur_heap" nonconcurrent
DETAIL: Create index in transaction block cannot be concurrent.
HINT: Consider running it outside of a transaction block. See https://github.com/yugabyte/yugabyte-db/issues/6240.
COMMIT;
7 changes: 7 additions & 0 deletions src/postgres/src/test/regress/sql/yb_create_table.sql
Expand Up @@ -540,3 +540,10 @@ select relname, oid from pg_class where relname = 'with_table_oid_2';
-- Test with session variable off
set yb_enable_create_with_table_oid=0;
create table with_table_oid_variable_false (a int) with (table_oid = 55555);
RESET yb_enable_create_with_table_oid;

-- CREATE TABLE with implicit UNIQUE INDEX shouldn't spout a notice about it
-- being nonconcurrent.
BEGIN;
CREATE TABLE tab_with_unique (i int, UNIQUE (i));
COMMIT;
20 changes: 20 additions & 0 deletions src/postgres/src/test/regress/sql/yb_pg_create_index.sql
Expand Up @@ -37,3 +37,23 @@ CREATE INDEX rix ON road USING lsm (name text_ops);
CREATE INDEX iix ON ihighway USING lsm (name text_ops);

CREATE INDEX six ON shighway USING lsm (name text_ops);

--
-- Try some concurrent index builds
--
-- Unfortunately this only tests about half the code paths because there are
-- no concurrent updates happening to the table at the same time.

CREATE TABLE concur_heap (f1 text, f2 text);
-- empty table
CREATE INDEX CONCURRENTLY concur_index1 ON concur_heap(f2,f1);

-- You can't do a concurrent index build in a transaction
BEGIN;
CREATE INDEX CONCURRENTLY concur_index7 ON concur_heap(f1);
COMMIT;

-- But you can do a regular index build in a transaction
BEGIN;
CREATE INDEX std_index on concur_heap(f2);
COMMIT;

0 comments on commit eb59b23

Please sign in to comment.