S
S
Sergey Eremin2020-09-01 12:40:17
MySQL
Sergey Eremin, 2020-09-01 12:40:17

Why does MySQL inside a Docker container abort (cancel) "long" requests?

An interesting feature was discovered (see subject). There is a container. yml like this:

version: "2.1"
services:
   database:
      container_name: mysql8_v001
      image: mysql:latest
      volumes:
         # - "d:/docker-compose/mysql/cfg:/etc/mysql"
         - "d:/docker-compose/mysql/data:/var/lib/mysql"
      environment:
         - "MYSQL_ROOT_PASSWORD=пароль"
         - "MYSQL_ROOT_HOST=10.10.10.10"
      ports:
         - "3306:3306"
      command: --bind-address="0.0.0.0" --skip_ssl="true" --wait_timeout="300" --mysqlx_read_timeout="300" --mysqlx_connect_timeout="300" --net_read_timeout="300"

As you can see, it works under Windows. And if the query execution time exceeds 31 seconds, then such a query is not executed. For example:

SELECT DISTINCT
  COUNT(scraper_tbhosts.id) AS NUM
FROM scraper_tbhosts
  LEFT OUTER JOIN taggit_taggeditem
    ON taggit_taggeditem.object_id = scraper_tbhosts.id
  INNER JOIN taggit_tag
    ON taggit_taggeditem.tag_id = taggit_tag.id
WHERE taggit_tag.name IN ('http', 'https')
AND taggit_taggeditem.content_type_id = 7

... will be interrupted. And exactly the same request:

SELECT DISTINCT
  COUNT(scraper_tbhosts.id) AS NUM
FROM scraper_tbhosts
  LEFT OUTER JOIN taggit_taggeditem
    ON taggit_taggeditem.object_id = scraper_tbhosts.id
  INNER JOIN taggit_tag
    ON taggit_taggeditem.tag_id = taggit_tag.id
WHERE taggit_tag.name NOT IN ('http', 'https')
AND taggit_taggeditem.content_type_id = 7

... will be executed (5.8 seconds, returns NUM something in the region of one and a half million).

The difference is in INor NOT IN, which means that everything depends only on the execution time on my data set...

As you can see: the setting in the mysql config has no effect. And even more, immediately after the container is reloaded, the request can be executed (in my opinion, only if this is the first request after the container is reloaded) and the execution time is 1 minute 50 seconds ... Re-execution of the request is interrupted by a timeout ... I.e. . it's in some other MySQL settings, or in Dockers... but where and what is wrong??

PS Yeah, I'm writing a parser-researcher of the entire Internet and the request is trying to understand which hosts do not respond either via http or https (i.e. hosts that fell off on tamayuts returned an error code not equal to 200, etc.)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
neol, 2020-09-01
@Sergei_Erjemin

Mysql has more than one timeout

SHOW VARIABLES WHERE Variable_name LIKE '%timeout%';

For example, net_read_timeout is 30 by default, maybe you are running into it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question