Page MenuHomePhabricator

My Toolforge bot can't execute an SQL request that quickly executes on Quarry
Closed, ResolvedPublic

Description

Some of my bots are doing an SQL request to create a list of all bot accounts in ruwiki's history. It can be done by simple SQL request

select distinct log_title from logging where log_type="rights" and log_params like '%bot%';

(that request returns all users who have ever received bot flag).
This request successfully executes in several seconds on Quarry: https://quarry.wmflabs.org/query/23016
Earlier I successfully execute it from my Toolforge bot, that use DB replicas. But in last month and today this request from bot always leads to an error:

MySql.Data.MySqlClient.MySqlException (0x80004005): Fatal error encountered during command execution. ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Fatal error encountered attempting to read the resultset. ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Reading from the stream has failed. ---> System.IO.IOException: Unable to read data from the transport connection: Operation on non-blocking socket would block. ---> System.Net.Sockets.SocketException: Operation on non-blocking socket would block
  at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags) [0x00016] in <fc308f916aec4e4283e0c1d4b761760a>:0 
  at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x0009b] in <fc308f916aec4e4283e0c1d4b761760a>:0 
   --- End of inner exception stack trace ---
  at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x000e2] in <fc308f916aec4e4283e0c1d4b761760a>:0 
  at MySql.Data.MySqlClient.TimedStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x00026] in <4f93ec5cee7d499da6a85a364813afe3>:0 
  at MySql.Data.MySqlClient.MySqlStream.ReadFully (System.IO.Stream stream, System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x00006] in <4f93ec5cee7d499da6a85a364813afe3>:0 
  at MySql.Data.MySqlClient.MySqlStream.LoadPacket () [0x0000e] in <4f93ec5cee7d499da6a85a364813afe3>:0 
  at MySql.Data.MySqlClient.MySqlStream.LoadPacket () [0x000a5] in <4f93ec5cee7d499da6a85a364813afe3>:0 
  at MySql.Data.MySqlClient.MySqlStream.ReadPacket () [0x00000] in <4f93ec5cee7d499da6a85a364813afe3>:0 
  at MySql.Data.MySqlClient.NativeDriver.GetResult (System.Int32& affectedRow, System.Int64& insertedId) [0x00026] in <4f93ec5cee7d499da6a85a364813afe3>:0 
  at MySql.Data.MySqlClient.Driver.GetResult (System.Int32 statementId, System.Int32& affectedRows, System.Int64& insertedId) [0x00000] in <4f93ec5cee7d499da6a85a364813afe3>:0 
  at MySql.Data.MySqlClient.Driver.NextResult (System.Int32 statementId, System.Boolean force) [0x00023] in <4f93ec5cee7d499da6a85a364813afe3>:0 
  at MySql.Data.MySqlClient.MySqlDataReader.NextResult () [0x000d5] in <4f93ec5cee7d499da6a85a364813afe3>:0 
  at MySql.Data.MySqlClient.MySqlDataReader.NextResult () [0x001f3] in <4f93ec5cee7d499da6a85a364813afe3>:0 
  at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader (System.Data.CommandBehavior behavior) [0x00248] in <4f93ec5cee7d499da6a85a364813afe3>:0 
  at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader (System.Data.CommandBehavior behavior) [0x0030b] in <4f93ec5cee7d499da6a85a364813afe3>:0 
  at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader () [0x00000] in <4f93ec5cee7d499da6a85a364813afe3>:0 
  at (wrapper remoting-invoke-with-check) MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
  at Program.Main (System.String[] args) [0x00060] in <f168bf067f6c43a48d89dc7c0b935147>:0

My bot is written on C#, uses a fresh version of Oracle MySql.Data library and runs from mono. Every other my C#/mono bots works successfully.
Note: in fact, a SQL request using in my bot is slightly different from Quarry's request. Real bot request is

select distinct cast(log_title as char) bot from logging where log_type='rights' and log_params like '%bot%';

If cast to char would not be done, all non-Latin letters in answer will be corrupted.

Event Timeline

MBH created this task.Dec 1 2019, 5:00 AM
Restricted Application added subscribers: Base, Aklapper. · View Herald TranscriptDec 1 2019, 5:00 AM
Marostegui added a subscriber: Marostegui.

I have tested both queries on the hosts themselves and they do work fine (as expecting seeing the quarry results you pasted). Could it be something with your client/connectors? Are you running the last versions?

bd808 added a subscriber: bd808.Dec 28 2019, 11:51 PM

"System.IO.IOException: Unable to read data from the transport connection: Operation on non-blocking socket would block." sounds like a problem with the C# code or its mysql library rather than the database service.

MBH closed this task as Resolved.Thu, Jan 2, 8:28 AM
MBH claimed this task.

"Fatal error encountered during command execution" was unclear message about timeout error. When I increased allowable working time for request, problem was solved.