vitessio / vitess

Vitess is a database clustering system for horizontal scaling of MySQL.
http://vitess.io
Apache License 2.0
18.59k stars 2.1k forks source link

VTgate --query-timeout is ignored #13694

Closed angelUrg closed 1 month ago

angelUrg commented 1 year ago

Overview of the Issue

The initial problem is that we have a joins queries like this: select a.SchemeId as Id, a.Enabled, a.SegmentId, b.CompanyName, shb.IsProfileEnabled from table1 as a join schemes as b on b.Id = a.SchemeId join table2 as shb on a.SchemeId = shb.SchemeId where a.SchemeId = 'xxx' and a.ConfigurationID = 'xxx';

This queries are creating a lot of scatter queries which we want to kill or prevent from running too long so we've tried with --query-timeout.

The query on our test environment was running for 12 seconds so we've set --query-timeout to 3000ms, restarted vtgate but and run the query again - it wasn't killed after 3 seconds, finished successfully after 12 seconds.

For the sake of the test we've changed --query-timeout to 500ms and here we had a result but it was killing 100% of the queries executed , no matter JOIN, SELECT or other.

Reproduction Steps

The part of the vschema for these tables:

{
    "sharded": true,
    "vindexes": {
        "identity_keyspace_binary": {
            "type": "binary"
        }
        "table1": {
            "columnVindexes": [{
                "column": "KeySpaceId",
                "name": "identity_keyspace_binary"
            }]
        },
        "table2": {
            "columnVindexes": [{
                "column": "KeySpaceId",
                "name": "identity_keyspace_binary"
            }]
        },

Binary Version

16.0.2

Operating System and Environment details

CentOS 7
Linux 5.15.49-linuxkit-pr
aarch64

Log Fragments

The scatter queries created by Vitess are not visible, only the one entered by us.
GrahamCampbell commented 4 months ago

I think this is happening because the timeout doesn't apply to the outer query. It is only applied to the individual queries sent to each vttablet.