A connection interruption was encountered while executing a specific query
P粉148782096
P粉148782096 2024-03-22 10:12:35
0
1
380

I receive a 2013 Lost Connection to MySQL server message during a query to MySQL hosted on an AWS instance. The query below is the only one that causes this error (other queries run fine), and this query runs without issue on a Synology Docker container running MySQL. The only unique thing I found is that this query uses a CTE while the other successfully running queries do not. AWS MySQL is 8.0.23 and NAS Docker MySQL is 8.0.28. I've checked the first things like max connections, timeouts, etc. and the AWS instance is using the same or higher values ​​than the settings on the NAS Docker instance. I've also tried using smaller data tables and reorganizing the data tables to eliminate the possibility of data corruption. I've been searching for a few days but can't find any hints as to what the problem is. Does anyone here have any suggestions on where I should go next? Thanks!

USE ce_test;
SET @lowlim = 0;
SET @upplim = 0;
with orderedList AS (
SELECT
    576_VMC_Sol_Savings_Pct,
    ROW_NUMBER() OVER (ORDER BY 576_VMC_Sol_Savings_Pct) AS row_n
FROM vmctco
),

quartile_breaks AS (
SELECT
    576_VMC_Sol_Savings_Pct,
    (
    SELECT 576_VMC_Sol_Savings_Pct AS quartile_break
    FROM orderedList
    WHERE row_n = FLOOR((SELECT COUNT(*) FROM vmctco)*0.75)
    ) AS q_three_lower,
    (
    SELECT 576_VMC_Sol_Savings_Pct AS quartile_break
    FROM orderedList
    WHERE row_n = FLOOR((SELECT COUNT(*) FROM vmctco)*0.75) + 1
    ) AS q_three_upper,
    (
    SELECT 576_VMC_Sol_Savings_Pct AS quartile_break
    FROM orderedList
    WHERE row_n = FLOOR((SELECT COUNT(*) FROM vmctco)*0.25)
    ) AS q_one_lower,
    (
    SELECT 576_VMC_Sol_Savings_Pct AS quartile_break
    FROM orderedList
    WHERE row_n = FLOOR((SELECT COUNT(*) FROM vmctco)*0.25) + 1
    ) AS q_one_upper
    FROM orderedList
    ),

iqr AS (
SELECT
    576_VMC_Sol_Savings_Pct,
    (
    (SELECT MAX(q_three_lower)
        FROM quartile_breaks) +
    (SELECT MAX(q_three_upper)
        FROM quartile_breaks)
    )/2 AS q_three,
    (
    (SELECT MAX(q_one_lower)
        FROM quartile_breaks) +
    (SELECT MAX(q_one_upper)
        FROM quartile_breaks)
    )/2 AS q_one,
    1.5 * ((
    (SELECT MAX(q_three_lower)
        FROM quartile_breaks) +
    (SELECT MAX(q_three_upper)
        FROM quartile_breaks)
    )/2 - (
    (SELECT MAX(q_one_lower)
        FROM quartile_breaks) +
    (SELECT MAX(q_one_upper)
        FROM quartile_breaks)
    )/2) AS outlier_range
FROM quartile_breaks
)

SELECT MAX(q_one) OVER () - MAX(outlier_range) OVER () AS lower_limit,
    MAX(q_three) OVER () + MAX(outlier_range) OVER () AS upper_limit
INTO @lowlim, @upplim
FROM iqr
LIMIT 1;

SELECT @lowlim, @upplim;

P粉148782096
P粉148782096

reply all(1)
P粉322319601

Resolved: I went ahead and updated the version on the AWS instance to the same version as the NAS (8.0.28) and the queries now run correctly.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!