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

Redundant check on prebuilt::n_rows_fetched overflow

    XMLWordPrintable

Details

    Description

      In an InnoDB record cursor, there is a counter row_prebuilt_t::n_rows_fetched that counts records that have been fetched in a key range scan. The main purpose of this counter is to control whether to trigger a prefetch of a cache that is slated for removal in MDEV-16232.

      On 64-bit systems, this counter cannot overflow. If we overestimate that InnoDB could read 10¹² or 2⁴⁰ records per second in a range scan, it would take more than half a year of such a range scan before the counter would wrap around. An even more rigid limitation would be that InnoDB only supports 2³² pages per tablespace, and you could fit at most a few thousand or 2¹² records per page, that is, there can't be more than some 2⁴⁴ records per index.

      I would propose to revise an overflow check as follows, disabling it on 64-bit systems:

      diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc
      index 4504fabd4e0..b217f6d20fe 100644
      --- a/storage/innobase/row/row0sel.cc
      +++ b/storage/innobase/row/row0sel.cc
      @@ -4406,13 +4406,11 @@ row_search_mvcc(
       			goto func_exit;
       		}
       
      +#if SIZEOF_SIZE_T < 8
      +		if (UNIV_LIKELY(~prebuilt->n_rows_fetched))
      +#endif
       		prebuilt->n_rows_fetched++;
       
      -		if (prebuilt->n_rows_fetched > 1000000000) {
      -			/* Prevent wrap-over */
      -			prebuilt->n_rows_fetched = 500000000;
      -		}
      -
       		mode = pcur->search_mode;
       	}
       
      

      Attachments

        Issue Links

          Activity

            People

              marko Marko Mäkelä
              marko Marko Mäkelä
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.