Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-35817

MAX_EXECUTION_TIME does not honor SLEEP(.5)

Details

    Description

      This issue is sporadic, and possibly [OS] timing related. For me it replays once every 1 to 13 attempts, provided the server is restarted each attempt.

      SELECT /*+ MAX_EXECUTION_TIME(1) */ SLEEP(.5); 
      

      Leads to, pre-patch:

      CS 11.8.0 7734c85c31c9e292ef1133115fba2f7edd71dd51 (Optimized)

      11.8.0-opt>SELECT /*+ MAX_EXECUTION_TIME(1) */ SLEEP(.5);    # Note the extra syntax is not valid and ignored here
      +-----------+
      | SLEEP(.5) |
      +-----------+
      |         0 |
      +-----------+
      1 row in set (0.500 sec)
      

      Versus post-patch:

      bb-11.8-MDEV-35504-opt-hints CS 11.8.0 6d92aa1cf0a042e506189b6739e03a8b45e20ee7 (Optimized)

      11.8.0-opt>SELECT /*+ MAX_EXECUTION_TIME(1) */ SLEEP(.5);
      +-----------+
      | SLEEP(.5) |
      +-----------+
      |         1 |
      +-----------+
      1 row in set (0.002 sec)
      

      Note the incorrect 0.002 sec as well as the '1' output. When the feature works as epected we instead see:

      bb-11.8-MDEV-35504-opt-hints CS 11.8.0 6d92aa1cf0a042e506189b6739e03a8b45e20ee7 (Optimized)

      11.8.0-opt>SELECT /*+ MAX_EXECUTION_TIME(1) */ SLEEP(.5); 
      ERROR 1969 (70100): Query execution was interrupted (max_statement_time exceeded)
      

      Additionally, and though not related to the feature, as the following reports a warning:

      bb-11.8-MDEV-35504-opt-hints CS 11.8.0 6d92aa1cf0a042e506189b6739e03a8b45e20ee7 (Optimized)

      11.8.0-opt>SELECT /*+ INVALID(1) */ SLEEP(.5);
      +-----------+
      | SLEEP(.5) |
      +-----------+
      |         0 |
      +-----------+
      1 row in set, 1 warning (0.500 sec)
       
      11.8.0-opt>SHOW WARNINGS;
      +---------+------+----------------------------------------------------------------------+
      | Level   | Code | Message                                                              |
      +---------+------+----------------------------------------------------------------------+
      | Warning | 1064 | Optimizer hint syntax error near 'INVALID(1) */ SLEEP(.5)' at line 1 |
      +---------+------+----------------------------------------------------------------------+
      1 row in set (0.000 sec)
      

      one would expect a similar warning pre-patch for the there-invalid MAX_EXECUTION_TIME hint, which is not present as can be seen from the first output above.
      Perhaps this can be fixed at the same time, or we can open a new ticket.

      Attachments

        Issue Links

          Activity

            Roel Roel Van de Paar added a comment - - edited

            The issue does not reproduce under MTR, irrespective of how many parallel threads, repeats,restarts and/or server kills etc. are used.
            Please use the native CLI, either directly (with restarts/fresh data dirs) or with some script. For me the following worked well:

            while true; do anc; ./test; if ! grep -q '1969' ./mysql.out; then break; fi; ./kill; done
            

            Where anc is a shortcut script that brings up a new server instance with a fresh data dir, and mysql.out is the output written by ./test which does:

            ./bin/mariadb -A -uroot -S./socket.sock --force --binary-mode test < in.sql > mysql.out 2>&1
            

            And in.sql contained the original testcase posted above. This produces the issue once every 1 to 13 loops.

            Roel Roel Van de Paar added a comment - - edited The issue does not reproduce under MTR, irrespective of how many parallel threads, repeats,restarts and/or server kills etc. are used. Please use the native CLI, either directly (with restarts/fresh data dirs) or with some script. For me the following worked well: while true ; do anc; . /test ; if ! grep -q '1969' . /mysql .out; then break ; fi ; . /kill ; done Where anc is a shortcut script that brings up a new server instance with a fresh data dir, and mysql.out is the output written by ./test which does: . /bin/mariadb -A -uroot -S. /socket .sock --force --binary-mode test < in .sql > mysql.out 2>&1 And in.sql contained the original testcase posted above. This produces the issue once every 1 to 13 loops.

            The issue does not seem to replicate to for example (not terminating) large JOINs.

            Roel Roel Van de Paar added a comment - The issue does not seem to replicate to for example (not terminating) large JOINs.

            As discussed, the issue does not reproduce with

            SET STATEMENT max_statement_time=1 FOR SELECT SLEEP(1.5);
            

            Roel Roel Van de Paar added a comment - As discussed, the issue does not reproduce with SET STATEMENT max_statement_time=1 FOR SELECT SLEEP(1.5);
            oleg.smirnov Oleg Smirnov added a comment -

            Roel, as we discussed on Slack, I could not reproduce the issue. Please check if you can repeat this on another machine.

            oleg.smirnov Oleg Smirnov added a comment - Roel , as we discussed on Slack, I could not reproduce the issue. Please check if you can repeat this on another machine.

            The issue is not reproducible on another instance. And, after a server reboot the issue is no longer reproducible on the original machine.
            Ftm, it seems like it was a temporary fluke on a GCP instance. Will reopen if seen again.

            Roel Roel Van de Paar added a comment - The issue is not reproducible on another instance. And, after a server reboot the issue is no longer reproducible on the original machine. Ftm, it seems like it was a temporary fluke on a GCP instance. Will reopen if seen again.

            People

              Unassigned Unassigned
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.