Expected to read 4 header bytes but only received 0.
See original GitHub issueThe issue
This error is thrown on SaveChanges
in one Web Api Action, every time. Other Actions don’t have this issue.
I am updating about 20 entries in this SaveChanges, more than in others. After getting this error in this one place a few times, other actions also starts throwing it. After a few seconds they go back to normal.
I am using the latest MySQL on Google Cloud, and I am using SSL for connections. I am surprised at how little info on this issue is on the web, and this seems to be a completely generic error.
connect_timeout 10 delayed_insert_timeout 300 have_statement_timeout YES innodb_flush_log_at_timeout 1 innodb_lock_wait_timeout 50 innodb_rollback_on_timeout OFF interactive_timeout 28800 lock_wait_timeout 31536000 net_read_timeout 30 net_write_timeout 600 rpl_stop_slave_timeout 31536000 slave_net_timeout 30 wait_timeout 28800
Exception message: Stack trace:
System.IO.EndOfStreamException: Expected to read 4 header bytes but only received 0.
at MySqlConnector.Protocol.Serialization.ProtocolUtility.<DoReadPayloadAsync>g__AddContinuation|5_0(ValueTask`1 readPacketTask, BufferedByteReader bufferedByteReader, IByteHandler byteHandler, Func`1 getNextSequenceNumber, ArraySegmentHolder`1 previousPayloads, ProtocolErrorBehavior protocolErrorBehavior, IOBehavior ioBehavior) in /_/src/MySqlConnector/Protocol/Serialization/ProtocolUtility.cs:line 476
at MySqlConnector.Core.ServerSession.ReceiveReplyAsyncAwaited(ValueTask`1 task) in /_/src/MySqlConnector/Core/ServerSession.cs:line 943
Further technical details
MySQL version: 8.0.18-google Pomelo.EntityFrameworkCore.MySql version: 6.0.1 Microsoft.AspNetCore.App version: 6.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Well, I have found a bug in MySQL. One of my commands was a DELETE command which was causing the error. Google Cloud MySql log was showing: “The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains information that should help you find out what is causing the crash.”
Anyways, this DELETE statement would try to delete a row from a table, and do a CASCADE delete from another table (foreign key). Besides cascade delete, another interesting thing is that the child table has a multi-valued index on one of its json columns. These two things combined, with or without transaction, crash the MySql.
If I delete the child row manually, it works. If I drop the index and delete the parent row, it deletes the parent and the child row.
Thanks for the help, everyone. I will try and report this to MySql people.
@SavoInfostream Nice detective work! Thanks for letting us know and for reporting it to the MySQL team.