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

[YSQL] Creating a table using "IF NOT EXISTS" sometimes throws "type ... already exists" #1991

Open
aphyr opened this issue Aug 7, 2019 · 1 comment

Comments

@aphyr
Copy link

commented Aug 7, 2019

On YugaByte DB 1.3.1.0, creating a YSQL table using CREATE TABLE ... IF NOT EXISTS mostly works, but on occasion, throws an error like:

org.postgresql.util.PSQLException: ERROR: type "append3" already exists
  Hint: A relation has an associated type of the same name, so you must use a name that doesn't conflict with any existing type.

For an example with logs, see 20190807T111825.000-0400.zip.

You can reproduce this with Jepsen c16f47674a342c7ac7ae5933261ad6ddbb14336a by running lein run test-all --os debian --version 1.3.1.0 --time-limit 5 -w ysql/append --test-count 50. Takes a few dozen runs on average before it shows up. It might be worth us devising specific tests for table creation, because it seems like there are lots of ways it can fail.

@frozenspider frozenspider changed the title Creating a table using "IF NOT EXISTS" sometimes throws "type ... already exists" [YSQL] Creating a table using "IF NOT EXISTS" sometimes throws "type ... already exists" Aug 7, 2019

@frozenspider frozenspider added this to To do in Jepsen Testing via automation Aug 7, 2019

@frozenspider frozenspider added this to To do in SQL Support via automation Aug 7, 2019

@bmatican bmatican added the area/sql label Aug 14, 2019

@ndeodhar

This comment has been minimized.

Copy link
Contributor

commented Aug 19, 2019

This is related to #1476.

Here's what I see in the logs:

./n1/master/logs/yb-master.n1.root.log.INFO.20190807-151833.28950:name: "append4"                    
./n1/master/logs/yb-master.n1.root.log.INFO.20190807-151833.28950:I0807 15:19:43.319483 29060 catalog_manager.cc:1933] Successfully created table append4 [id=000030a5000030008000000000004014] per request from 192.168.122.12:45388
./n1/master/logs/yb-master.n1.root.log.INFO.20190807-151833.28950:I0807 15:19:49.596141 29875 async_rpc_tasks.cc:471] TS 55b91e2f160c4dd2a3d386ba707184b5: tablet 3bbecaab53f14cf8b6ec06108dde9a22 (table append4 [id=000030a50000300080000000
./n1/master/logs/yb-master.n1.root.log.INFO.20190807-151833.28950:name: "append4"                    
./n1/master/logs/yb-master.n1.root.log.INFO.20190807-151833.28950:I0807 15:19:54.351409 29727 catalog_manager.cc:1933] Successfully created table append4 [id=000030a5000030008000000000004017] per request from 192.168.122.12:45788

We processed and created two tables (note that they have different UUIDs) when we should have detected and failed the second duplicate request. This happened because we only store postgres tables in id maps and not in name maps in catalog manager. So, for the second request, we tried to look up the table append4 by its name, didn't find an entry and created a duplicate table.

This will be fixed as a result of #1476.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5 participants
You can’t perform that action at this time.