-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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: table creation freeze on version 2.0-beta #23718
Comments
@0xBAADF00D I'm unable to reproduce this issue. Are you running it on a fresh cluster? Can you run the CREATE TABLE from the cockroach CLI? |
Hello, I'm running on a fresh node, single node, run with --insecure. I work on my dev computer. Tested with Windows and MacOS version of Cockroach. The issue only appear on version 2.0-beta and only via Ebean Migration. The strange behavior is, if the table "db_migration" already exists, everything works well, all migration scripts are run with success. Only the table creation freeze. I could create a sample Java project to test the bahavior if it could help you? |
We know that a CREATE TABLE that is attempting to create a table that was created by another transaction that has yet to commit can hang indefinitely. Something like
And this has nothing to do with version 2.0 |
it is surely something else, the same code works with the version 1.1.5 but not with 2.0-beta. |
Note that the code (migration runner) in question is using a single JDBC Connection (not with autoCommit), creating the table and then selecting from that table. I suspect it is actually the select that is hanging and not the create table ... will look to confirm that later today (maybe a question of if commit() is needed after the create table and before the select from that table). |
Yes, the hang is on the select query that follows the create table.
Now in general (well, other databases) we ideally do not want to run DB Migration scripts with autoCommit = true ... and these scripts contain a mix of DDL and DML. The question I'd have at the moment is what is the expected limitations with respect to transactions and running DDL. Is it required that there is a COMMIT after DDL statements? I note that we are:
It seems that any DML executed on a newly created table in the same transaction (without a commit or autoCommit) hangs. e.g. 10:50:56.643 [main] DEBUG io.ebean.DDL - executing 1 of 3 create table m3 (id integer, acol varchar(20), bcol timestamp)
10:50:56.653 [main] DEBUG io.ebean.DDL - executing 2 of 3 alter table m1 add column addcol varchar(10)
10:50:56.685 [main] DEBUG io.ebean.DDL - executing 3 of 3 insert into m3 (id, acol) VALUES (1, 'text with ; sign') The If we run everything with autoCommit = true ... (and no explicit connection.commit()) then it all runs without any error. |
There are a few restrictions to running DDL statements within transactions, for instance you cannot DROP and CREATE the same table in the same transactions. But the transactions you point out should work. In particular they seem to be working with the 1.1.5 release as you mention. I've tried to reproduce the problem with no luck. Can you send me the exact sequence of statements within the transaction. Thanks |
I've added some examples in the attached PR that work fine on our master branch |
I'd appreciate it if you can send me the exact sequence of sql statements that were run within the transactions. Thanks for all the information so far! |
23816: sql: stop using txn.OrigTimestamp to reset TableCollection r=vivekmenezes a=vivekmenezes Release note: None #23718 24616: ui: upgrade React 15.4 => 16.3 r=vilterp a=vilterp Fixes #18795 Release note: None Co-authored-by: Vivek Menezes <[email protected]> Co-authored-by: Pete Vilter <[email protected]>
24874: backport-2.0: sql: stop using txn.OrigTimestamp to reset TableCollection r=vivekmenezes a=vivekmenezes Backport 1/1 commits from #23816. /cc @cockroachdb/release --- sql: Stop using txn.OrigTimestamp to reset TableCollection We use the transaction OrigTimestamp to figure out if a transaction is being retried, triggering a reset of TableCollection. This logic would get triggered when running PREPARE within a transaction, because PREPARE uses it's own transaction and thus has a different OrigTimestamp. Removed this logic because transaction retries trigger resetting the TableCollection in the new conn-executor code. fixes #24578 Release note sql: fix PREPARE hanging when run in the same transaction as a CREATE TABLE possibly related #23718 Co-authored-by: Vivek Menezes <[email protected]>
@vivekmenezes moving this to the bulk io project. Needs to be triaged. |
I'm gonna close this issue. We made a number of improvements here. In particular we now allow running schema changes and DML statements in the same transaction as the CREATE TABLE statement. #24626 |
Description
I'm using Ebean ORM with Ebean migration (Java / JDBC). Everything works on CockroachDB 1.1.5 but with 2.0-beta, the process hang (freeze) on the creation of the table "db_migration".
During this "freeze", the instruction "SHOW TABLES;" hand too. If I kill the Java application, the currently blocked instruction "SHOW TABLES;" return results.
Ebean create the table with this SQL instruction:
CockroachDB version
Output from Java application
Output from CockroachDB
The text was updated successfully, but these errors were encountered: