Bug: fseg_get_pages_info does not release pages during extent iteration

未關閉
#54 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
57/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
冷清
技術堆疊
cpp
領域
databases

研究方向

先閱讀 storage/innobase/fsp/fsp0fsp.cc 中的 fseg_get_pages_info(),然後檢查 storage/innobase/include/mtr0mtr.h 和 storage/innobase/mtr/mtr0mtr.cc 中 mtr_t 的宣告與實作。追蹤 issue 中描述的 CHECK INDEX 路徑。完成的標準是:extent 掃描限定所保留的頁面閂鎖,同時保留現有的頁面資訊結果和 CHECK INDEX 行為。

由索引模型根據 Issue 內容生成。

描述

Bug: fseg_get_pages_info does not release pages during extent iteration

Problem

In fseg_get_pages_info() (storage/innobase/fsp/fsp0fsp.cc), when scanning the FSEG_NOT_FULL and FSEG_FULL extent lists for a segment, the mtr holds latches on every visited page descriptor (xdes) without releasing them until the entire function completes and mtr_commit() is called.

For tables with a large number of extents (large tables or tables with fragmented segments), this can mean holding hundreds or thousands of page latches simultaneously within a single mini-transaction. This causes:

  • Excessive buffer pool frame consumption (each latched page pins a buffer pool frame)
  • Increased memory pressure and potential OOM
  • CHECK INDEX on large tables becomes unreliable (may OOM)

Root Cause

The mtr_t memo stack grows unbounded during extent list traversal in fseg_get_pages_info(). Each call to xdes_lst_get_descriptor() and xdes_mtr_get_bit() adds a page latch to the mtr memo, but these latches are only released at mtr_commit() which happens at the very end of the function.

Fix

Add a new function mtr_t::release_all_after_savepoint() that releases all pages held in the mtr memo after a given savepoint. Then in fseg_get_pages_info(), set a savepoint and release pages every 100 iterations, effectively bounding the number of simultaneously held latches.

Changes
  1. storage/innobase/include/mtr0mtr.h: Declare release_all_after_savepoint(ulint savepoint) method and mtr_release_all_after_savepoint() macro.

  2. storage/innobase/mtr/mtr0mtr.cc: Implement Release_all_after_savepoint functor and mtr_t::release_all_after_savepoint() method.

  3. storage/innobase/fsp/fsp0fsp.cc: In fseg_get_pages_info(), add savepoint and release logic every 100 pages during FSEG_NOT_FULL and FSEG_FULL list scans.

Affected Scenarios

  • CHECK INDEX on large tables — ha_innobase::check_index() → innobase_get_index_status() → fseg_get_pages_info() for both leaf and top segments of each index
主要語言
C++
星號
712
分支
428
平均合併
5 小時 43 分鐘
30 天內合併 PR
1

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

OpenTenBase/TXSQL 的其他 Issue

查看 OpenTenBase/TXSQL 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。