-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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: DDL statements are non-transactional #24785
Comments
Hi @gpaul, Unfortunately, our DDL statements are not transactional today. This is definitely confusing as you've seen here, and it's something we'd like to address in the future. We have to allow issuing them within transactions for Postgres compatibility, since many tools issue them that way, even though they don't respect the bounds of said transaction. I'm not sure if there's a larger tracking issue for transactional DDL somewhere, I wasn't able to find one, @vivekmenezes, do you know if we have one? |
this looks like the same issue as #24626. Please reopen if you think differently. Thanks! |
Indeed that is confusing. Does that mean half of the CREATE TABLE statements may execute successfully while others fail silently? The part that confuses me is the silent failure. I issued INSERT statements followed immediately by That is quite different from #24626 where the user got an error "pq: foreign key requires an existing index on columns ("parent_id")". In my case, the transaction succeeds successfully. |
I can also confirm that if I remove the |
@vivekmenezes I think there is something different going on than in #24626. Inserting into a table in the same transaction the table is created in should work. For example:
I imagine the |
I can confirm that this problem is not on 2.0 |
and I can confirm that this problem is present on 1.1.7 |
@gpaul would you like us to figure out what the problem with 1.1 is regarding this issue or are you comfortable that it's not an issue in 2.0+ ? Thanks! |
related to cockroachdb#24785 Release note: None
Responded in DM |
Hey @vivekmenezes! We would certainly appreciate to have this issue addressed in the 1.1 release branch as soon as possible. Given the number of issues we ran into in the 1.0 and 1.1 branches we are not comfortable updating to 2.0 just like that -- it appears to be an entirely new thing and it will take us a while to build up trust in its reliability. For now, we would like to continue to use 1.1.x to not throw away what we've learned from using it in production. |
@andreimatei assigning to you as the sql executor guru |
This does not appear to affect v1.0.6 |
It also affects v1.1.4 |
smaller repro on 1.1 in our logictest language:
|
The issue is that, even after the |
Even smaller repro; the following commits just fine and leaves a dangling row.
I believe the problem is with the logic for resolving "uncommitted" tables - in 1.1 we didn't reset a session's set of uncommitted tables on transaction restart. Should have a fix soon. |
Well, here's one... I can fix the "dangling row" bug, but while testing that I've found another issue that's also present at master. The following sequence deadlocks:
The reason why it deadlocks is that the I guess the deadlock is better than the "dangling row" state of affairs, so I guess I'll bring 1.1 up to par with 2.0 and open a different issue for the deadlock. |
…epoint Prior to this patch, the following sequence would write a row that's then unaccessible: begin; savepoint cockroach_restart; create table t(x int primary key); rollback to savepoint cockroach_restart; insert into t(x) values(1); release savepoint cockroach_restart; commit; The insert manages to resolve the table because we weren't clearing the "uncommitted descriptors" set that the session maintains. Since the table descriptor doesn't end up being committed, the row will be essentially unreachable. This patch is original work on the 1.1 branch. This bug is not present in the 2.0 release, where we're better about reseting state on transaction retries. I believe on 1.1 there's still a similar issue present when doing automatic retries (as opposed to user-directed ones through rollback to savepoint). I think fixing those would be more involved because it's less clear where to stick the cleanup done in this patch; I'd rather not do anything this point. Also note that, with the fix, the sequence above doesn't actually work. Instead, it deadlocks, just like it does on 2.0, because of cockroachdb#24885. However, the following works: begin; savepoint cockroach_restart; create table t(x int primary key); rollback to savepoint cockroach_restart; create table t(x int primary key); insert into t(x) values(1); release savepoint cockroach_restart; commit; Fixes cockroachdb#24785
24888: sql: Fix "dangling rows" left over by schema change + rollback to savepoint r=andreimatei a=andreimatei Prior to this patch, the following sequence would write a row that's then unaccessible: begin; savepoint cockroach_restart; create table t(x int primary key); rollback to savepoint cockroach_restart; insert into t(x) values(1); release savepoint cockroach_restart; commit; The insert manages to resolve the table because we weren't clearing the "uncommitted descriptors" set that the session maintains. Since the table descriptor doesn't end up being committed, the row will be essentially unreachable. This patch is original work on the 1.1 branch. This bug is not present in the 2.0 release, where we're better about reseting state on transaction retries. I believe on 1.1 there's still a similar issue present when doing automatic retries (as opposed to user-directed ones through rollback to savepoint). I think fixing those would be more involved because it's less clear where to stick the cleanup done in this patch; I'd rather not do anything this point. Also note that, with the fix, the sequence above doesn't actually work. Instead, it deadlocks, just like it does on 2.0, because of #24885. However, the following works: begin; savepoint cockroach_restart; create table t(x int primary key); rollback to savepoint cockroach_restart; create table t(x int primary key); insert into t(x) values(1); release savepoint cockroach_restart; commit; Fixes #24785 cc @cockroachdb/release @gpaul Co-authored-by: Andrei Matei <andrei@cockroachlabs.com>
Thanks for the great work.
Does that mean it's present in 1.1.7 or only on master? If it is present in 1.1.7: how likely are we going to run into that after the 'dangling row' fix? |
@andreimatei is this closed by #24888? |
@jgehrcke , as we were talking, #24885 is present on both 1.1.x and 2.0.x. But you don't run into it if either you do the same schema changes after a @jordanlewis yes. A commit in that PR had "Fixes #24785"... I wonder why this was not closed? Does a bug only get closed when |
Yes. Only commits that get merged into master are scanned for |
Is this a question, feature request, or bug report?
BUG REPORT
Please supply the header (i.e. the first few lines) of your most recent
log file for each node in your cluster. On most unix-based systems
running with defaults, this boils down to the output of
grep -F '[config]' cockroach-data/logs/cockroach.log
Start a single node cluster:
Create a database called 'testdb':
Execute the following commands one by one (note the ROLLBACK SAVEPOINT halfway through followed by re-issuing of the transaction's contents):
I expect a user in the users table if it exists, or no users and no tables:
No user in the database, but tables are present:
The text was updated successfully, but these errors were encountered: