MariaDB存储过程异常信息:意外的流结束,读取0字节时发生错误
P粉004287665
2023-08-26 22:16:32
<p>我们在MariaDB中有一个存储过程,在服务器上运行良好,但是当我们使用JDBC从客户端运行时,我们可以获取到前几行,但是后面总是出现以下错误:</p>
<pre class="brush:php;toolbar:false;">unexpected end of stream, read 0 bytes from 4 (socket was closed by server)</pre>
<p>表<code>loan_balances2</code>不是太大,大约有600K行。这是存储过程,你看到有什么问题吗?谢谢!</p>
<pre class="brush:php;toolbar:false;">CREATE PROCEDURE `get_loan_balances_sample`()
BEGIN
drop table if exists all_loan_ids;
drop table if exists random_loan_ids;
create table all_loan_ids as select distinct loan_id from loan_balances2;
create table random_loan_ids as select * from all_loan_ids order by RAND() limit 50;
SELECT * FROM loan_balances2
where loan_id in (select Loan_ID from random_loan_ids)
order by Loan_ID, balance_date;
END</pre></p>
通常是net_write_timeout。如果您的应用程序无法以服务器写入速度读取数据,服务器将关闭套接字。net_write_timeout是服务器尝试发送结果集的时间限制,以秒为单位。您可以增加该限制,这是一个会话变量。这也出现在MariaDB JDBC的常见问题解答中。