apecloud / myduckserver

MySQL & Postgres Analytics, Reimagined
187 stars 9 forks source link

DuckDB Transaction Abort Error #89

Open GaoYusong opened 2 months ago

GaoYusong commented 2 months ago

The error occurs if waitForFixQueries is set to empty in TestQuerySimple. I haven’t found a simple way to reproduce it yet.

    --- FAIL: TestQueriesSimple/select_*_from_mytable_where_(i_BETWEEN_(''_BETWEEN_''_AND_(''_OR_'#'))_AND_i) (0.01s)
        /Users/ysg/code/myduckserver/evaluation.go:351: 
                Error Trace:    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/enginetest/evaluation.go:351
                Error:          Received unexpected error:
                                Binder Error: Cannot mix values of type VARCHAR and BOOLEAN in BETWEEN clause - an explicit cast is required
                                LINE 1: ...CT * FROM mytable WHERE (i BETWEEN ('' BETWEEN '' AND ('' OR '#')) AND i)
                                                                                  ^
                Test:           TestQueriesSimple/select_*_from_mytable_where_(i_BETWEEN_(''_BETWEEN_''_AND_(''_OR_'#'))_AND_i)
                Messages:       Unexpected error for query select * from mytable where (i BETWEEN ('' BETWEEN '' AND ('' OR '#')) AND i): Binder Error: Cannot mix values of type VARCHAR and BOOLEAN in BETWEEN clause - an explicit cast is required
                                LINE 1: ...CT * FROM mytable WHERE (i BETWEEN ('' BETWEEN '' AND ('' OR '#')) AND i)
                                                                                  ^
    --- FAIL: TestQueriesSimple/select_*_from_xy_inner_join_uv_on_(xy.x_in_(false_in_('asdf'))); (0.02s)
        /Users/ysg/code/myduckserver/evaluation.go:351: 
                Error Trace:    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/enginetest/evaluation.go:351
                Error:          Received unexpected error:
                                Conversion Error: Could not convert string 'asdf' to BOOL
                                LINE 1: ...y INNER JOIN uv ON (xy.x IN (FALSE IN ('asdf')))
                                                                                  ^
                Test:           TestQueriesSimple/select_*_from_xy_inner_join_uv_on_(xy.x_in_(false_in_('asdf')));
                Messages:       Unexpected error for query select * from xy inner join uv on (xy.x in (false in ('asdf')));: Conversion Error: Could not convert string 'asdf' to BOOL
                                LINE 1: ...y INNER JOIN uv ON (xy.x IN (FALSE IN ('asdf')))
                                                                                  ^
    --- FAIL: TestQueriesSimple/select_*_from_mytable_where_i_>_'-0.5'; (0.00s)
        /Users/ysg/code/myduckserver/evaluation.go:351: 
                Error Trace:    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/enginetest/evaluation.go:351
                Error:          Received unexpected error:
                                duckdb: TransactionContext Error: Current transaction is aborted (please ROLLBACK)

                                github.com/apecloud/myduckserver/catalog.hasDatabase
                                    /Users/ysg/code/myduckserver/catalog/provider.go:168
                                github.com/apecloud/myduckserver/catalog.(*DatabaseProvider).Database
                                    /Users/ysg/code/myduckserver/catalog/provider.go:141
                                github.com/dolthub/go-mysql-server/sql/mysql_db.PrivilegedDatabaseProvider.Database
                                    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/sql/mysql_db/privileged_database_provider.go:53
                                github.com/dolthub/go-mysql-server/sql/analyzer.(*Catalog).Database
                                    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/sql/analyzer/catalog.go:176
                                github.com/dolthub/go-mysql-server/sql/planbuilder.(*Builder).buildResolvedTable
                                    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/sql/planbuilder/from.go:643
                                github.com/dolthub/go-mysql-server/sql/planbuilder.(*Builder).buildResolvedTableForTablename
                                    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/sql/planbuilder/from.go:626
                                github.com/dolthub/go-mysql-server/sql/planbuilder.(*Builder).buildTablescan
                                    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/sql/planbuilder/from.go:622
                                github.com/dolthub/go-mysql-server/sql/planbuilder.(*Builder).buildDataSource
                                    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/sql/planbuilder/from.go:284
                                github.com/dolthub/go-mysql-server/sql/planbuilder.(*Builder).buildFrom
                                    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/sql/planbuilder/from.go:59
                                github.com/dolthub/go-mysql-server/sql/planbuilder.(*Builder).buildSelect
                                    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/sql/planbuilder/select.go:62
                                github.com/dolthub/go-mysql-server/sql/planbuilder.(*Builder).buildSelectStmt
                                    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/sql/planbuilder/select.go:36
                                github.com/dolthub/go-mysql-server/sql/planbuilder.(*Builder).buildSubquery
                                    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/sql/planbuilder/builder.go:199
                                github.com/dolthub/go-mysql-server/sql/planbuilder.(*Builder).build
                                    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/sql/planbuilder/builder.go:188
                                github.com/dolthub/go-mysql-server/sql/planbuilder.(*Builder).Parse
                                    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/sql/planbuilder/parse.go:77
                                github.com/dolthub/go-mysql-server.(*Engine).bindQuery
                                    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/engine.go:589
                                github.com/dolthub/go-mysql-server.(*Engine).QueryWithBindings
                                    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/engine.go:390
                                github.com/dolthub/go-mysql-server/enginetest.TestQueryWithContext
                                    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/enginetest/evaluation.go:350
                                github.com/dolthub/go-mysql-server/enginetest.TestQueries.func1
                                    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/enginetest/enginetests.go:72
                                testing.tRunner
                                    /opt/homebrew/Cellar/go/1.23.1/libexec/src/testing/testing.go:1690
                                runtime.goexit
                                    /opt/homebrew/Cellar/go/1.23.1/libexec/src/runtime/asm_arm64.s:1223
                Test:           TestQueriesSimple/select_*_from_mytable_where_i_>_'-0.5';
                Messages:       Unexpected error for query select * from mytable where i > '-0.5';: duckdb: TransactionContext Error: Current transaction is aborted (please ROLLBACK)
    --- FAIL: TestQueriesSimple/select_case_when_1_then_59_+_81_/_1_end; (0.00s)
panic: duckdb: TransactionContext Error: Current transaction is aborted (please ROLLBACK) [recovered]
    panic: duckdb: TransactionContext Error: Current transaction is aborted (please ROLLBACK)

goroutine 10490 [running]:
testing.tRunner.func1.2({0x103650f00, 0x1400140a600})
    /opt/homebrew/Cellar/go/1.23.1/libexec/src/testing/testing.go:1632 +0x1bc
testing.tRunner.func1()
    /opt/homebrew/Cellar/go/1.23.1/libexec/src/testing/testing.go:1635 +0x334
panic({0x103650f00?, 0x1400140a600?})
    /opt/homebrew/Cellar/go/1.23.1/libexec/src/runtime/panic.go:785 +0x124
github.com/apecloud/myduckserver/catalog.(*DatabaseProvider).AllDatabases(0x140004fbac0, 0x1400061c0a0)
    /Users/ysg/code/myduckserver/catalog/provider.go:110 +0x464
github.com/dolthub/go-mysql-server/sql/mysql_db.PrivilegedDatabaseProvider.AllDatabases({0x140004b7cc0?, {0x1037a3d78?, 0x140004fbac0?}}, 0x1400061c0a0)
    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/sql/mysql_db/privileged_database_provider.go:107 +0x74
github.com/dolthub/go-mysql-server/sql/analyzer.(*Catalog).AllDatabases(0x140004a4b00, 0x1400061c0a0)
    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/sql/analyzer/catalog.go:112 +0xb0
github.com/dolthub/go-mysql-server/sql/analyzer.assignRoutines.func1({0x1037ae180, 0x140014041e0})
    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/sql/analyzer/assign_routines.go:53 +0x1ac
github.com/dolthub/go-mysql-server/sql/transform.Node({0x1037ae180, 0x140014041e0}, 0x14000059808)
    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/sql/transform/node.go:320 +0x88
github.com/dolthub/go-mysql-server/sql/transform.Node({0x1037ae0e0, 0x140014c0c30}, 0x14000059808)
    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/sql/transform/node.go:330 +0xf8
github.com/dolthub/go-mysql-server/sql/analyzer.assignRoutines(0x1400061c0a0?, 0x140004a4b80, {0x1037ae0e0, 0x140014c0c30}, 0x0, 0x103791dc8, 0x140004902f0?)
    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/sql/analyzer/assign_routines.go:37 +0xc0
github.com/dolthub/go-mysql-server/sql/analyzer.(*Batch).evalOnce(0x1026161f5?, 0x1400061c0a0, 0x140004a4b80, {0x1037ae0e0?, 0x140014c0c30?}, 0x0, 0x103791dc8, 0x140004902f0)
    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/sql/analyzer/batch.go:87 +0x1d8
github.com/dolthub/go-mysql-server/sql/analyzer.(*Batch).EvalWithSelector(0x1037ae0e0?, 0x140014c0c30?, 0x140004a4b80, {0x1037ae0e0?, 0x140014c0c30?}, 0x0?, 0x1026161f5?, 0x27?)
    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/sql/analyzer/batch.go:61 +0x11c
github.com/dolthub/go-mysql-server/sql/analyzer.(*Batch).Eval(...)
    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/sql/analyzer/batch.go:53
github.com/dolthub/go-mysql-server/sql/analyzer.(*Analyzer).analyzeWithSelector(0x140004a4b80, 0x105ef77f0?, {0x1037ae0e0, 0x140014c0c30}, 0x0, 0x103791dd0, 0x103791dc8, 0x140004902f0)
    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/sql/analyzer/analyzer.go:538 +0x36c
github.com/dolthub/go-mysql-server/sql/analyzer.(*Analyzer).Analyze(...)
    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/sql/analyzer/analyzer.go:491
github.com/dolthub/go-mysql-server.(*Engine).analyzeNode(0x1400063b5e0?, 0x1400061c0a0?, {0x1026161f5?, 0x27?}, {0x1037ae0e0?, 0x140014c0c30?}, 0x0?)
    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/engine.go:578 +0x3b0
github.com/dolthub/go-mysql-server.(*Engine).QueryWithBindings(0x1400063b5e0, 0x1400061c0a0, {0x1026161f5, 0x28}, {0x0, 0x0}, 0x0, 0x0)
    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/engine.go:395 +0x118
github.com/dolthub/go-mysql-server/enginetest.TestQueryWithContext(0x140013b21a0, 0x14000d8d400?, {0x1037b8268, 0x14000cdf8f0}, {0x1037a6df8, 0x140001f4600}, {0x1026161f5, 0x28}, {0x1040b7f70, 0x1, ...}, ...)
    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/enginetest/evaluation.go:350 +0x1c0
github.com/dolthub/go-mysql-server/enginetest.TestQueries.func1(0x140013b21a0)
    /Users/ysg/.gopath/pkg/mod/github.com/dolthub/go-mysql-server@v0.18.2-0.20240815142344-761713e36043/enginetest/enginetests.go:72 +0x184
testing.tRunner(0x140013b21a0, 0x14000e92180)
    /opt/homebrew/Cellar/go/1.23.1/libexec/src/testing/testing.go:1690 +0xe4
created by testing.(*T).Run in goroutine 5
    /opt/homebrew/Cellar/go/1.23.1/libexec/src/testing/testing.go:1743 +0x314