Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.2(EOL), 10.3(EOL), 10.4(EOL), 10.5, 10.6
-
None
Description
This is continuation of MDEV-24176
fix_all_session_vcol_exprs() works on expr_arena which allocates from table memory pool (TABLE::mem_root). Since expr_arena does not free its items until TABLE is destroyed, continuous work with virtual columns under some circumstances (FIXME: get test case from MDEV-16039 or from main.default_session ) leads to memory leak until table is flushed.
The problem is common to use cases of long-living query arenas (FIXME: get more cases).
Discover the idea of making temporary query subarena with it's own item free-list. fix_fields() should run on that subarena and freeing its list will not delete items from the master arena. Freeing master arena items list should free subarena list as well. cleanup() procedure should be tied with that temporary subarena and remove all temporary pointers from master items. And either cleanup() process should automatically free temporary subarena or vice versa the subarena initiates cleanup() of master items. The final goal is that after subarena destroy there is no stale pointers in master items.
Another more straightforward approach is to destroy query arena on each command. The items are transferred to new arena via build_clone(). That approach is coupled with a number of problems: delayed insert, items clone does not do String::copy() for their properties, cached_table cleanup, proper name resolution context, etc. The proof-of-concept in bb-10.2-midenok-MDEV-25794 tries to fix them to some level of success.
Note that after this fix granular refix via VCOL_NOT_STRICTLY_DETERMINISTIC flags will not be needed.
Attachments
Issue Links
- is blocked by
-
MDEV-24176 Server crashes after insert in the table with virtual column generated using date_format() and if()
- Closed
- relates to
-
MDEV-16039 Crash when selecting virtual columns generated using functions with DAYNAME()
- Closed
-
MDEV-25672 table alias from previous statement interferes later commands
- Closed