Skip to content
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

"Connection reset by peer" on certain SELECT and CALL statements #253

Open
rideron89 opened this issue Nov 3, 2020 · 2 comments
Open

"Connection reset by peer" on certain SELECT and CALL statements #253

rideron89 opened this issue Nov 3, 2020 · 2 comments

Comments

@rideron89
Copy link

11/03/2020 Update: I was having this problem yesterday, after a couple more run attempts it just started working. No code/server/configuration changes. Now it is back to throwing the error again.


I have a relatively complex SELECT statement (35 lines; some UNIONs in a subquery) that is hanging for about 20 seconds before the following error:

CodecError { IO error: `Connection reset by peer (os error 104)' }

Here is my truncated code:

let pool = {
    let options = OptsBuilder::new()
        .ip_or_hostname(Some(&self.config.database.host))
        .tcp_port(self.config.database.port)
        .db_name(Some(&self.config.database.db_name))
        .user(Some(&self.config.database.user))
        .pass(Some(&self.config.database.pass));

    Pool::new(options)?
};

// ...

#[derive(Clone, Debug, Serialize)]
pub struct Account {
    pub zoho_id: String,
    pub corporate_group: String,
    pub corporate_group_number: usize,
    pub total_insureds: i64,
}

impl mysql::prelude::FromRow for Account {
    fn from_row_opt(row: mysql::Row) -> Result<Self, mysql::FromRowError> {
        let zoho_id = row.get_opt(0).unwrap().map_err(|_| mysql::FromRowError(row.clone()))?;
        let corporate_group = row.get_opt(1).unwrap().map_err(|_| mysql::FromRowError(row.clone()))?;
        let corporate_group_number = row.get_opt(2).unwrap().map_err(|_| mysql::FromRowError(row.clone()))?;
        let total_insureds = row.get_opt(3).unwrap().map_err(|_| mysql::FromRowError(row.clone()))?;

        Ok(Self {
            zoho_id,
            corporate_group,
            corporate_group_number,
            total_insureds,
        })
    }
}

// ...

let sql = "CALL getAccountsChurn()";
let accounts = pool.get_conn()?.query_map(sql, |account: Account| account)?;

26 records of 4 columns are to be returned, so I don't think it is a size issue. I can run the same statement in my interactive client (HeidiSQL), the command line, and a separate PHP app just fine. The queries takes about 1-2 seconds to complete.

I moved the select statements into simple stored procedures (with just the select statement), and a couple of the queries started working, but not all of them.

When I run SHOW PROCESSLIST while it's hanging, all pooled connections are sleeping.

I'm using MariaDB 10.3.8 on Windows Server 2016. Here are my SQL timeout settings:

interactive_timeout = 28800
net_read_timeout = 28800
net_write_timeout = 28800
thread_pool_idle_timeout = 60
wait_timeout = 28800

The only MariaDB error message I get is this one at the time I receive the os error 104 in my client:

[Warning] Aborted connection 34 to db: 'db_name' user: 'root' host: '192.168.0.99' (Got an error reading communication packets)

I'm really not sure what to blame. But I figure I'll put in this report, just in case there is a weird edge bug to be found.

@blackbeam
Copy link
Owner

Hi. Thanks for report.
Regarding your database instance - is it on local or remote host?

@rideron89
Copy link
Author

rideron89 commented Nov 3, 2020

Hello! The database is remote (and connected through a VPN). I am also using WSL 2 (Debian) locally under Windows 10.

I just compiled for Windows and it works both locally (through Windows) and remote. So it might be a WSL 2 issue.

In case this helps, here are my build targets (couldn't get windows-msvc to compile debug):

Local (WSL): x86_64-unknown-linux-gnu (debug) [broken]
Local: x86_64-pc-windows-msvc (release) [works]
Remote: x86_64-pc-windows-msvc (release) [works]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants