MariaDB stored procedure exception information: Unexpected end of stream, error reading 0 bytes
P粉004287665
2023-08-26 22:16:32
<p>We have a stored procedure in MariaDB that runs fine on the server, but when we run it from the client using JDBC, we can get the first few rows, but always get the following error afterwards: </p> ;
<pre class="brush:php;toolbar:false;">unexpected end of stream, read 0 bytes from 4 (socket was closed by server)</pre>
<p>Table<code>loan_balances2</code> is not too big, about 600K rows. This is a stored procedure, do you see anything wrong with it? Thanks! </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>
Usually net_write_timeout. If your application cannot read data at the server's write speed, the server will close the socket. net_write_timeout is the time limit, in seconds, for the server to attempt to send a result set. You can increase this limit, which is a session variable. This also appears in MariaDB JDBC's FAQ.