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

Random missing rows from result with jemalloc

    XMLWordPrintable

Details

    Description

      Hello,
      after enabling jemalloc, we started to get random missing rows from result - sometimes 4 rows, sometimes 3 rows, sometime 2 rows ....

      I was able to create minimal reproducible that shows error both with mariadb:10.6.15 and current master quay.io/mariadb-foundation/mariadb-devel:10.6 with jemalloc turned on. Without jemalloc everything works.

      This is preview of repro: https://dbfiddle.uk/rXJGvk_h - e-shop with order items, every item has link to product and each product has more sections

      The main cause seems to be this part of query. We use subselect in JOIN to join always only one section with highest priority:

      ...
      LEFT JOIN sections s ON s.id = (
      SELECT s2.id
      FROM sections s2
      LEFT JOIN products_sections ps ON s2.id = ps.id_section
      WHERE ps.id_product = p.id
      ORDER BY s2.priority DESC
      LIMIT 1
      )
      ...

      when I remove ORDER BY it behaves normally. The problem seems to be that subselect matches two rows with same priority, so it picks random row. And sometimes it leads to completely missing row in result - it is an error, LEFT JOIN should never remove rows from result. When I run this query 10 times, I get 5 times 4 rows, 5 times only 3 rows.

      I'm able to test this on newer Mariadb versions if it will help.

      Attachments

        Activity

          People

            igor Igor Babaev
            cuchac Cuchac
            Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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