Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/backend/commands/resgroupcmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "commands/resgroupcmds.h"
#include "miscadmin.h"
#include "nodes/pg_list.h"
#include "storage/proc.h"
#include "utils/builtins.h"
#include "utils/datetime.h"
#include "utils/fmgroids.h"
Expand Down Expand Up @@ -716,10 +717,17 @@ GetResGroupIdForRole(Oid roleid)
HeapTuple tuple;
Oid groupId;
bool isNull;
bool releaseSnapshot;
Relation rel;
ScanKeyData key;
SysScanDesc sscan;

/*
* StartTransaction() might hold a catalog snapshot with a valid xmin.
* As this fails the "CREATE INDEX CONCURRENTLY" status checks, explicitly
* release the snapshot.
*/
releaseSnapshot = MyProc->xmin == InvalidTransactionId;
rel = table_open(AuthIdRelationId, AccessShareLock);

ScanKeyInit(&key,
Expand Down Expand Up @@ -757,6 +765,9 @@ GetResGroupIdForRole(Oid roleid)
*/
table_close(rel, AccessShareLock);

if (releaseSnapshot)
InvalidateCatalogSnapshot();

if (!OidIsValid(groupId))
groupId = InvalidOid;

Expand Down
13 changes: 13 additions & 0 deletions src/test/isolation2/expected/resgroup/resgroup_transaction.out
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,16 @@ DROP
-- cleanup
DROP VIEW rg_test_monitor;
DROP

-- ----------------------------------------------------------------------
-- Test: "CREATE INDEX CONCURRENTLY" when compiled with enable-cassert
-- ----------------------------------------------------------------------

CREATE TABLE t(a text, b text);
CREATE
CREATE INDEX CONCURRENTLY t_idx ON t(a, b);
CREATE
DROP INDEX CONCURRENTLY t_idx;
DROP
DROP TABLE t;
DROP
9 changes: 9 additions & 0 deletions src/test/isolation2/sql/resgroup/resgroup_transaction.sql
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,12 @@ DROP FUNCTION rg_drop_func();

-- cleanup
DROP VIEW rg_test_monitor;

-- ----------------------------------------------------------------------
-- Test: "CREATE INDEX CONCURRENTLY" when compiled with enable-cassert
-- ----------------------------------------------------------------------

CREATE TABLE t(a text, b text);
CREATE INDEX CONCURRENTLY t_idx ON t(a, b);
DROP INDEX CONCURRENTLY t_idx;
DROP TABLE t;
Loading