Skip to content

[fix](be) fix disk metrics staying empty on LVM/device-mapper mounts - #67536

Open
sinhaparth5 wants to merge 1 commit into
apache:masterfrom
sinhaparth5:fix/be-lvm-disk-metrics
Open

[fix](be) fix disk metrics staying empty on LVM/device-mapper mounts#67536
sinhaparth5 wants to merge 1 commit into
apache:masterfrom
sinhaparth5:fix/be-lvm-disk-metrics

Conversation

@sinhaparth5

@sinhaparth5sinhaparth5 commented Sep 4, 2026

Copy link
Copy Markdown

What problem does this PR solve?

Issue Number: close#62365

Problem Summary:

BE disk metrics come back empty when a data dir sits on an LVM (device-mapper) volume.

DiskInfo::get_disk_devices() in be/src/util/disk_info.cpp looks up a mount's device by comparing basenames: it takes the device column from /proc/mounts, strips trailing digits (sda2 -> sda), and checks that name against the table get_device_names() built from /proc/partitions. For an LVM mount, /proc/mounts shows /dev/mapper/<vg-lv>, which never matches the dm-N name /proc/partitions uses, so the lookup always fails and no per-disk metrics get installed for that mount.

get_device_names() already builds _s_device_id_to_disk_id, a table keyed by the device's real dev_t (major:minor), for exactly this kind of lookup. get_disk_devices() just wasn't using it. This PR resolves the mount's device with stat() and matches on st_rdev against that table instead of comparing names.

Also stopped trimming trailing digits off dm-N names in get_device_names(). For a regular disk the digits mark a partition (sda1, sda2 are both sda), but for device-mapper the number identifies a distinct logical volume, not a partition, so dm-0 and dm-1 were being collapsed into one bogus dm- entry.

Added be/test/util/disk_info_test.cpp covering the extracted DiskInfo::strip_partition_suffix helper.

Release note

None

Check List (For Author)

  • Test
    • Unit Test
    • Manual test (add detailed scripts or steps below)

Manual test: hand-traced the /proc/mounts / /proc/partitions parsing against a real LVM layout (/dev/mapper/vg-lv0 mounted, backed by dm-0) to confirm the new stat()-based match resolves correctly, plus the new unit test for strip_partition_suffix. Also running the BE unit test build on a separate box to confirm DiskInfoTest.* passes; will update this PR when that finishes.

  • Behavior changed:

    • No.
    • Yes. Disk metrics now populate for data dirs on LVM/device-mapper mounts, which previously stayed empty.
  • Does this need documentation?

    • No.

DiskInfo::get_disk_devices() matched a mount's device against the
table get_device_names() builds from /proc/partitions by comparing
basenames with trailing digits stripped (sda2 -> sda). For an LVM
mount, /proc/mounts lists the device as /dev/mapper/<vg-lv>, which
never matches the dm-N name /proc/partitions uses. The match always
failed, so no disk metrics were installed for that mount.
Resolve the device with stat() instead and match on its real dev_t
(major:minor) against _s_device_id_to_disk_id, the table
get_device_names() already keys by dev_t for exactly this purpose.
Also stop stripping trailing digits from dm-N names: for
device-mapper, the number identifies a distinct logical volume, not
a partition of one shared disk, so dm-0 and dm-1 were collapsing
into a single bogus "dm-" entry.
Added be/test/util/disk_info_test.cpp for the extracted
strip_partition_suffix helper.
Fixesapache#62365
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] The BE disk metrics value is empty when use LVM

2 participants

@sinhaparth5@hello-stephen