-
Notifications
You must be signed in to change notification settings - Fork 5.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
Panic happen when input mismatch parameter number #39148
Comments
/severity major |
Formatted stack:
|
Maybe have some connection with #38116. The difference is that #38116 sets the parameter properly (but removed by TiDB while commit). And for this issue doesn't have enough parameters. Here is the backtrace. It seems that it affects jdbc only.
|
@YangKeao might be useful to check with Wireshark what the difference is between Connector/J and Connector/Python (with prepared statement cursor class) |
After several attempts, I cannot reproduce this problem:
I guess this problem is not because the parameter number mismatch, with two evidence:
One assumption I could provide is that the TiDB cannot handle two parallel fetch properly. You could verify it with the following java program (or any other connector supports cursor fetch): 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();
}
} It opens two cursor: one for statement1 with two parameters, and one for statement2 with one parameters. When it tries to read result from statement1, the TiDB will panic, as the parameters in the session has already been modified in the second statement. It produces nearly the same backtrace as shown in the issue, so I guess it's the root cause. @lizhenhuan Could you help to verify it? This issue actually shared the same root cause with #38116, both of them are because the session vars / statement vars of the cursor is shared with others. |
Thanks for the great explanation. I think this: |
Nice catch 👍 . Thanks |
As another issue has been created to track this big problem (#40094) and the user has adapted the work around, I'd close this issue. If you have more discovery over this issue, feel free to reopen or comment under this. |
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
用户 TiDB 节点持续重启,tidb log 中存在大量 panic 。
err="runtime error: index out of range [0] with length 0"
uptime monitor:
Welcome key word in tidb log
some log:
full log file:
tidb.log.tar.gz
2. What did you expect to see? (Required)
error log and return error info to user, tidb server not restart
3. What did you see instead (Required)
panic happen , tidb keep restart , server is not aviable
4. What is your TiDB version? (Required)
Server version: 5.7.25-TiDB-v6.3.0 TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible
Server version: 5.7.25-TiDB-v6.3.0 TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible
The text was updated successfully, but these errors were encountered: