OpenTenBase / OpenTenBase/TXSQL

Bug: fseg_get_pages_info does not release pages during extent iteration

オープン
#54 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
C++
スター
337
フォーク
234
PR マージ指標
30日以内にマージされた PR はありません

説明

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

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず 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 の本文から書いたものです。

評価

技術スタック
cpp
領域
databases
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
57/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。