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

create multiple cursor will cause panic #40094

Closed
YangKeao opened this issue Dec 21, 2022 · 1 comment · Fixed by #41441
Closed

create multiple cursor will cause panic #40094

YangKeao opened this issue Dec 21, 2022 · 1 comment · Fixed by #41441
Assignees
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.1 affects-6.5 affects-6.6 severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@YangKeao
Copy link
Member

YangKeao commented Dec 21, 2022

Bug Report

ref: #39148 (comment)

1. Minimal reproduce step (Required)

Run with mysql-connector-java:

public class Example {
    public static void main(String[] args) throws SQLException, InterruptedException {
        Connection conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:4000/test?useCursorFetch=true&useServerPrepStmts=true&useSSL=false", "root", "");

        conn.setAutoCommit(false); // must set

        conn.prepareStatement("drop table if exists t").execute();
        conn.prepareStatement("create table t (id int auto_increment primary key, id_2 int)").execute();
        conn.prepareStatement("insert into t values (1,1)").execute();
        conn.prepareStatement("insert into t values (2,2)").execute();

        // submit a statement with more arguments:
        PreparedStatement statement1 = conn.prepareStatement("" +
                "select * " +
                "from " +
                "t " +
                "where id = ? and id_2 = ?");
        statement1.setFetchSize(500);
        statement1.setInt(1, 1);
        statement1.setInt(2, 2);
        ResultSet rs_1 = statement1.executeQuery();

        // submit a statement with less arguments:
        PreparedStatement statement2 = conn.prepareStatement("" +
                "select * " +
                "from " +
                "t " +
                "where (id = ?)");
        statement2.setFetchSize(500);
        statement2.setInt(1, 1);
        ResultSet rs_2 = statement2.executeQuery();

        // fetch the result from the first argument
        while (rs_1.next()) {
            int result = rs_1.getInt(1);

            System.out.println(result);
        }

        conn.close();

    }
}

2. What did you expect to see? (Required)

Returns error, or print the result 1.

3. What did you see instead (Required)

tidb server panic.

4. What is your TiDB version? (Required)

Tested with master and 6.3

I'm afraid any existing version of TiDB has this problem.

@YangKeao YangKeao added the type/bug The issue is confirmed as a bug. label Dec 21, 2022
@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.0 may-affects-6.1 may-affects-6.2 may-affects-6.3 may-affects-6.4 labels Dec 21, 2022
@YangKeao YangKeao added affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. and removed may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-6.0 may-affects-6.1 may-affects-6.2 may-affects-6.3 may-affects-6.4 labels Dec 21, 2022
@YangKeao YangKeao added affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.1 affects-6.5 labels Dec 21, 2022
@tiancaiamao
Copy link
Contributor

A related PR #40023
@YangKeao

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.1 affects-6.5 affects-6.6 severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
4 participants