Skip to content

MDEV-24245 REPAIR/OPTIMIZE on ARCHIVE table corrupts blob/text data#5428

Open
vaintroub wants to merge 1 commit into
10.6from
10.6-MDEV-24245
Open

MDEV-24245 REPAIR/OPTIMIZE on ARCHIVE table corrupts blob/text data#5428
vaintroub wants to merge 1 commit into
10.6from
10.6-MDEV-24245

Conversation

@vaintroub

Copy link
Copy Markdown
Member

pack_row() and unpack_row() both used record_buffer. After unpack_row(), blob field pointers in record[0] reference data stored in record_buffer. When pack_row() then writes the new packed row into the same record_buffer, it overwrites the blob data that those pointers still reference. Subsequent Field_blob::pack() calls follow the stale pointers and read corrupted data.

This only matters in the optimize/repair loop where the same handler reads then writes each row. Normal INSERT has no prior unpack_row() on the same handler.

Fix: in the optimize loop, before writing, copy blob data out of record_buffer (the same approach already used by get_row_version2),so that blob pointers no longer reference record_buffer when pack_row() overwrites it.

Free the temporary blob buffer after the loop.

@vaintroub
vaintroub requested a review from Copilot July 21, 2026 14:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses a potential blob data corruption issue during table optimization in the archive storage engine (specifically for version 3 and above) by copying blob data out of the shared record buffer before packing. It also adds a test case to verify the fix. The review feedback identifies a critical issue where the return value of buffer.alloc() is not checked, which could lead to a null pointer dereference in out-of-memory conditions.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread storage/archive/ha_archive.cc Outdated
pack_row() and unpack_row() both used record_buffer. After unpack_row(),
blob field pointers in record[0] reference data stored in record_buffer.
When pack_row() then writes the new packed row into the same record_buffer,
it overwrites the blob data that those pointers still reference. Subsequent
Field_blob::pack() calls follow the stale pointers and read corrupted data.

This only matters in the optimize/repair loop where the same handler reads
then writes each row. Normal INSERT has no prior unpack_row() on the same
handler.

Fix: in the optimize loop, before writing, copy blob data out of
record_buffer (the same approach already used by get_row_version2),so that
blob pointers no longer reference record_buffer when pack_row() overwrites it.

Free the temporary blob buffer after the loop.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants