gpdb icon indicating copy to clipboard operation
gpdb copied to clipboard

gp_toolkit.gp_disk_free only show information about the disk used by the default tablespace

Open cobolbaby opened this issue 3 years ago • 1 comments
trafficstars

Bug Report

Greenplum version or build

OS version and uname -a

autoconf options used ( config.status --config )

Installation information ( pg_config )

Expected behavior

Actual behavior

$ docker exec -ti gp6sdw1 bash
[gpadmin@gp6sdw1 greenplum]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
overlay         196G   81G  106G  44% /
tmpfs            64M     0   64M   0% /dev
tmpfs           252G     0  252G   0% /sys/fs/cgroup
/dev/sdf        1.8T  1.5T  307G  83% /disk1/gpdata
/dev/sda        1.8T  373G  1.4T  21% /ssd1/gpdata
/dev/sdi        1.8T  1.5T  297G  84% /disk4/gpdata
/dev/sdd        1.8T  374G  1.4T  21% /ssd2/gpdata
/dev/sdb2       196G   81G  106G  44% /etc/hosts
shm              64M  320K   64M   1% /dev/shm
tmpfs           252G     0  252G   0% /proc/acpi
tmpfs           252G     0  252G   0% /proc/scsi
tmpfs           252G     0  252G   0% /sys/firmware
postgres=#  select * from gp_toolkit.gp_disk_free order by dfhostname, dfdevice
postgres-# ;
 dfsegment | dfhostname | dfdevice  |  dfspace  
-----------+------------+-----------+-----------
         0 |  gp6sdw1   |  /dev/sdf | 320029880
         1 |  gp6sdw1   |  /dev/sdf | 320029880
         2 |  gp6sdw1   |  /dev/sdi | 308518296
         3 |  gp6sdw1   |  /dev/sdi | 308518296
         5 |  gp6sdw2   |  /dev/sdf | 320034444
         4 |  gp6sdw2   |  /dev/sdf | 320034444
         7 |  gp6sdw2   |  /dev/sdi | 321545712
         6 |  gp6sdw2   |  /dev/sdi | 321545712
         9 |  gp6sdw3   |  /dev/sdf | 313813716
         8 |  gp6sdw3   |  /dev/sdf | 313813716
        10 |  gp6sdw3   |  /dev/sdi | 308310992
        11 |  gp6sdw3   |  /dev/sdi | 308310992
        12 |  gp6sdw4   |  /dev/sdh | 323588004
        13 |  gp6sdw4   |  /dev/sdh | 323588004
        15 |  gp6sdw4   |  /dev/sdi | 318234176
        14 |  gp6sdw4   |  /dev/sdi | 318234176
        17 |  gp6sdw5   |  /dev/sdf | 316216700
        16 |  gp6sdw5   |  /dev/sdf | 316216700
        19 |  gp6sdw5   |  /dev/sdi | 324651744
        18 |  gp6sdw5   |  /dev/sdi | 324651744
(20 rows)

Step to reproduce the behavior

cobolbaby avatar Jul 12 '22 04:07 cobolbaby

Nice catch!

Since gp_toolkit.gp_disk_free is a EXTERNAL TABLE that uses a python script to fetch information about the disk used:

from gppylib.commands import unix

df = unix.DiskFree.get_disk_free_info_local('token','$GP_SEG_DATADIR')

print('%s, %s, %s, %s' % ('$GP_SEGMENT_ID', unix.getLocalHostname(), df[0], df[3]))

As we can see, this script uses the default tablespace's directory, $GP_SEG_DATADIR. The easiest way to resolve this problem is by using \db to fetch all tablespaces and iterate the result to get the value of Location:

  • If Location is empty, just use the default directory;
  • Or use the absolute path

Summary all collected paths, invoke unix.DiskFree.get_disk_free_info_local().

SmartKeyerror avatar Jul 12 '22 08:07 SmartKeyerror