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

sql: drop table and recreate fail #7348

Closed
idsj opened this issue Jun 21, 2016 · 11 comments · Fixed by #13908
Closed

sql: drop table and recreate fail #7348

idsj opened this issue Jun 21, 2016 · 11 comments · Fixed by #13908
Assignees
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. C-question A question rather than an issue. No code/spec/doc change needed. O-community Originated from the community S-1-stability Severe stability issues that can be fixed by upgrading, but usually don’t resolve by restarting S-3-ux-surprise Issue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.
Milestone

Comments

@idsj
Copy link

idsj commented Jun 21, 2016

Please follow the steps below to help us help you.

  1. header
    I160621 11:06:31.940101 util/log/clog.go:998 [config] file created at: 2016/06/21 11:06:31
    I160621 11:06:31.940101 util/log/clog.go:998 [config] running on machine: longong-dsj-kv1
    I160621 11:06:31.940101 util/log/clog.go:998 [config] binary: CockroachDB beta-20160616 (linux amd64, built 2016/06/16 16:51:45, go1.6.2)
    I160621 11:06:31.940101 util/log/clog.go:998 [config] arguments: [./cockroach start --host=192.168.181.91 --insecure --join=192.168.181.92:26258]
  2. Please describe the issue you observed:
  • What did you do?
    e.g
    root@192.168.181.91:26257> drop table test_serial;
    DROP TABLE
    root@192.168.181.91:26257> select count(*) from test_serial;
    pq: table is being deleted
    root@192.168.181.91:26257> show tables;
    +-------------+
    | Table |
    +-------------+
    | test_serial |
    +-------------+
  • What did you expect to see?
    create a new table with same name
  • What did you see instead?
    i can not create a new table with same name
    e.g
    root@192.168.181.91:26257> create table test_serial(a serial primary key,b string(30),c bool);
    pq: table "test_serial" already exists
@andreimatei
Copy link
Contributor

Are you running the DROP statement in a transaction? If so, DDL statements only take effect when you commit the txn.

@idsj
Copy link
Author

idsj commented Jun 21, 2016

@andreimatei I'm not using the transaction actually, and after the statement, all the nodes got errors. I used to catch this situation when I drop a table with 1m+ records and I thought the reason lies in the table size, but now I meet the same error for table of only 10k+ size.

@andreimatei
Copy link
Contributor

Hmmm this "shouldn't happen" without a txn. I'll try to reproduce. Or if
you have a simple repro that you can share, that'd be useful.

On Tue, Jun 21, 2016 at 2:12 AM, idsj notifications@github.com wrote:

@andreimatei https://github.com/andreimatei I'm not using the
transaction actually, and after the statement, all the nodes got errors. I
used to catch this situation when I drop a table with 1m+ records and I
thought the reason lies in the table size, but now I meet the same error
for table of only 10k+ size.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#7348 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAXBcbtDQR0faui3C8EzvZQeJUI19o00ks5qN4DBgaJpZM4I6U3v
.

@vivekmenezes
Copy link
Contributor

I believe this is the intended behavior right. The name is available for
reuse only after thr table has been fully deleted.

On Tue, Jun 21, 2016, 12:10 PM Andrei Matei notifications@github.com
wrote:

Hmmm this "shouldn't happen" without a txn. I'll try to reproduce. Or if
you have a simple repro that you can share, that'd be useful.

On Tue, Jun 21, 2016 at 2:12 AM, idsj notifications@github.com wrote:

@andreimatei https://github.com/andreimatei I'm not using the
transaction actually, and after the statement, all the nodes got errors.
I
used to catch this situation when I drop a table with 1m+ records and I
thought the reason lies in the table size, but now I meet the same error
for table of only 10k+ size.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<
#7348 (comment)
,
or mute the thread
<
https://github.com/notifications/unsubscribe/AAXBcbtDQR0faui3C8EzvZQeJUI19o00ks5qN4DBgaJpZM4I6U3v

.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#7348 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ALOpBNlHu8TG9aWkIdlpJpTGo47Jdq0iks5qOA0IgaJpZM4I6U3v
.

@andreimatei
Copy link
Contributor

Right, but the table is truncated and "fully deleted" by the schema changer, which (when run through the "synchronous path") blocks the client executing the DROP.

@idsj
Copy link
Author

idsj commented Jun 22, 2016

@andreimatei
create a new cockroach cluster with three node(192.168.181.91/92/93);Then do follow:

root@192.168.181.91:26257> create database test;
CREATE DATABASE
root@192.168.181.91:26257> set database = test;
SET

/*
create a table named test_serial and insert 30000 records using the node(192.168.181.93);
*/

root@192.168.181.91:26257> show tables;
+-------------+
| Table |
+-------------+
| test_serial |
+-------------+
root@192.168.181.91:26257> select count() from test_serial;
+----------+
| count(
) |
+----------+
| 30000 |
+----------+
root@192.168.181.91:26257> drop table test_serial;
DROP TABLE
root@192.168.181.91:26257> show tables;
+-------------+
| Table |
+-------------+
| test_serial |
+-------------+
root@192.168.181.91:26257> select count(*) from test_serial;
pq: table is being deleted
root@192.168.181.91:26257> create table test_serial(a serial primary key,b string(30),c bool);
pq: table "test_serial" already exists
root@192.168.181.91:26257> drop table test_serial;
pq: table "test_serial" has been deleted
root@192.168.181.91:26257> show tables;
+-------------+
| Table |
+-------------+
| test_serial |
+-------------+
root@192.168.181.91:26257>

and the node(192.168.181.93) got error.

@andreimatei andreimatei self-assigned this Jun 22, 2016
@andreimatei
Copy link
Contributor

I couldn't manage to reproduce this. @idsj would you mind confirming you're running a recent build of cockroach? When you launch it with ./cockroach start, there should be a line in the log (or console, if you specify --logtostderr) like

build:     beta-20160609-328-g775699c @ 2016/06/24 18:59:25 (go1.6.2)

Also, can you confirm that the DROP statement takes a noticeable time to execute (a few secs)?

Also also would you mind trying to reproduce it using a single node cluster, just to see if that changes anything?

Thanks!

@idsj
Copy link
Author

idsj commented Jun 27, 2016

@andreimatei
i use the beta-20160616 version.The version message is as follow:
Build Tag: beta-20160616
Build Time: 2016/06/16 16:51:45
Platform: linux amd64
Go Version: go1.6.2
C Compiler: gcc 4.9.2

yes,it execute a few seconds.

Did you reproduce it using the cluster with VM? It did not happen in VM environment,i have done too. It happened in the physical machine environment.

@petermattis petermattis changed the title drop table and recreate fail sql: drop table and recreate fail Jun 27, 2016
@andreimatei
Copy link
Contributor

OK, managed to repro using three nodes. Looking.

@andreimatei
Copy link
Contributor

For an update here, a number of problems have been made apparent by this. There's an outright bug that would sometimes lead to this behavior that's being fixed in #7504.
More fundamentally, there's problems with humongous transactions, such as the one we use for a truncation. For example: #627

Ways to avoid a huge transaction for truncation are being discussed here: #7499

@petermattis petermattis added the S-1-stability Severe stability issues that can be fixed by upgrading, but usually don’t resolve by restarting label Jul 11, 2016
@petermattis petermattis added this to the Q3 milestone Jul 11, 2016
@knz knz added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. S-3-ux-surprise Issue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption. labels Oct 27, 2016
@vivekmenezes
Copy link
Contributor

We should fix this by renaming the table before dropping it.

vivekmenezes added a commit to vivekmenezes/cockroach that referenced this issue Mar 6, 2017
When dropping a table, the table name would be released only after
the table was truncated. Table truncation can take a long time and
it doesn't make for a good user experience when a user expects a
name for a dropped table to be available almost immediately.

fixes cockroachdb#7348
vivekmenezes added a commit to vivekmenezes/cockroach that referenced this issue Mar 6, 2017
When dropping a table, the table name would be released only after
the table was truncated. Table truncation can take a long time and
it doesn't make for a good user experience when a user expects a
name for a dropped table to be available almost immediately.

fixes cockroachdb#7348
vivekmenezes added a commit to vivekmenezes/cockroach that referenced this issue Mar 7, 2017
When dropping a table, the table name would be released only after
the table was truncated. Table truncation can take a long time and
it doesn't make for a good user experience when a user expects a
name for a dropped table to be available almost immediately.

fixes cockroachdb#7348
@jordanlewis jordanlewis added C-question A question rather than an issue. No code/spec/doc change needed. O-community Originated from the community and removed O-deprecated-community-questions labels Apr 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. C-question A question rather than an issue. No code/spec/doc change needed. O-community Originated from the community S-1-stability Severe stability issues that can be fixed by upgrading, but usually don’t resolve by restarting S-3-ux-surprise Issue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants