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

Systematic fix for allocations on read-only MEM_ROOT after first execution

    XMLWordPrintable

Details

    Description

      After the first execution of a prepared statement or stored routine, its MEM_ROOT is marked read-only (MY_ROOT_READ_ONLY, flag 4) so that later executions cannot allocate persistent memory on it. Few code paths still try to allocate lazily on such MEM_ROOT after first execution, triggering the assert (mem_root->flags & 4) == 0.

      Ex:

      CREATE PROCEDURE p(x INT DEFAULT (SELECT 1)) ...
      CALL p(1); -- first exec, marks mem_root read-only
      CALL p(); -- tries to allocate on locked mem_root when executing DEFAULT
      

      The current workaround is to clear the flag temporarily, allocate and again mark the mem_root read-only. This bypasses the protection and need a better strategy to handle such allocations.

      Attachments

        Activity

          People

            Unassigned Unassigned
            raghunandan.bhat Raghunandan Bhat
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.