OpenTenBase / OpenTenBase/TXSQL

Bug: fseg_get_pages_info does not release pages during extent iteration

Đang mở
#54 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
C++
Star
337
Fork
234
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách đọc fseg_get_pages_info() trong storage/innobase/fsp/fsp0fsp.cc, sau đó kiểm tra các khai báo và phần triển khai của mtr_t trong storage/innobase/include/mtr0mtr.h và storage/innobase/mtr/mtr0mtr.cc. Theo dõi đường đi CHECK INDEX được mô tả trong issue. Công việc được xem là hoàn tất khi các lần quét extent giới hạn các page latch được giữ lại, đồng thời duy trì các kết quả thông tin trang hiện có và hành vi của CHECK INDEX.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
cpp
Lĩnh vực
databases
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
57/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.