You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, the current version is not complete.
First domain (T_CreateDomainStmt) and enum (T_CreateEnumStmt) incorrectly do not increment the version.
Second, CREATE TABLE t also creates a type t implicitly (composite type with the table schema). So technically we should increment the catalog version for every create table as well (currently we only do it for some sub-cases of CREATE TABLE).
Repro
General setup
Create a simulated 3-node cluster (yugabyted instead of yb-ctl also works).
As expected this will fail and also it will add a negative entry in the system catalog cache for that type name.
CREATE TABLE test(c enum_tp1);
ERROR: type "enum_tp1" does not exist
LINE 1: CREATE TABLE test(c enum_tp1);
On connection 1 create a type enum_tp1
Because of the catalog version issue for enum types mentioned above this will not end up notifying connection 2 to invalidate that cache entry.
CREATE TYPE enum_tp1 AS ENUM ('a', 'b');
On connection 2 try to use the type enum_tp1
This should now succeed but on this connection it will fail.
CREATE TABLE test(c enum_tp1);
ERROR: type "enum_tp1" does not exist
LINE 1: CREATE TABLE test(c enum_tp1);
To confirm, on connection 1 (or any connection where that negative cache entry wasn't added) this will work fine.
CREATE TABLE test(c enum_tp1);
CREATE TABLE
Example 2
Note: Better to use fresh connections (re-run General setup section above) to avoid issues related to example 1.
On connection 2 try to use a type t1.
As expected this will fail and also it will add a negative entry in the system catalog cache for that type name.
CREATE TABLE test2(c t1);
ERROR: type "t1" does not exist
LINE 1: CREATE TABLE test2(c t1);
On connection 1 create a table t1
This will implicitly create a type t1 which will lead to same issue above -- this time due to CREATE TABLE (T_CreateStmt) not always incrementing catalog version.
CREATE TABLE t1(c1 int, c2 int);
On connection 2 try to use the type enum_tp1
This should now succeed but on this connection it will fail.
CREATE TABLE test2(c t1);
ERROR: type "t1" does not exist
LINE 1: CREATE TABLE test2(c t1);
To confirm, on connection 1 (or any connection where that negative cache entry wasn't added) this will work fine.
CREATE TABLE test2(c t1);
CREATE TABLE
The text was updated successfully, but these errors were encountered:
Jira Link: DB-4349
Description
In the latest versions we use negative caching for
pg_type
(TYPEOID
andTYPENAMENSP
).As a result we have increment the catalog version when we create a new type (so negative entries can be invalidated correctly).
See for instance the cases in: https://github.com/yugabyte/yugabyte-db/blob/master/src/postgres/src/backend/utils/misc/pg_yb_utils.c#L1332
However, the current version is not complete.
First domain (
T_CreateDomainStmt
) and enum (T_CreateEnumStmt
) incorrectly do not increment the version.Second,
CREATE TABLE t
also creates a typet
implicitly (composite type with the table schema). So technically we should increment the catalog version for every create table as well (currently we only do it for some sub-cases of CREATE TABLE).Repro
General setup
Create a simulated 3-node cluster (
yugabyted
instead ofyb-ctl
also works).Connect to node 1
Will call this connection 1 below
Connect to node 2
Will call this connection 2 below
Example 1
On connection 2 try to use a type
enum_tp1
.As expected this will fail and also it will add a negative entry in the system catalog cache for that type name.
On connection 1 create a type
enum_tp1
Because of the catalog version issue for enum types mentioned above this will not end up notifying connection 2 to invalidate that cache entry.
On connection 2 try to use the type
enum_tp1
This should now succeed but on this connection it will fail.
To confirm, on connection 1 (or any connection where that negative cache entry wasn't added) this will work fine.
Example 2
Note: Better to use fresh connections (re-run
General setup
section above) to avoid issues related to example 1.On connection 2 try to use a type
t1
.As expected this will fail and also it will add a negative entry in the system catalog cache for that type name.
On connection 1 create a table
t1
This will implicitly create a type
t1
which will lead to same issue above -- this time due to CREATE TABLE (T_CreateStmt
) not always incrementing catalog version.On connection 2 try to use the type
enum_tp1
This should now succeed but on this connection it will fail.
To confirm, on connection 1 (or any connection where that negative cache entry wasn't added) this will work fine.
The text was updated successfully, but these errors were encountered: