mariadb/plugin/disks
Dmitry Shulga eeb00ceffd MDEV-35617: DROP USER should leave no active session for that user
Follow-up patch with adjustments of test files and updates of result
files for tests.

Some of tests were rewritten slighlty. Everywhere where common
pattern used:
-----
  CREATE USER userA;
  --connect con1 ... userA ...
   <sql statements...>
  --disconnect con1
  DROP USER userA;
-----
the DROP USER statement has been eclosed into the directive
--disable_warnings
--enable_warnings

This change is caused by the race conddition between --disconnect
and DROP USER since a number of currently running sessions
established on behalf the user being dropped is counted by
holding the rw_lock THD_list_iterator::lock that is not acquired on
execution the DROP USER statement but the lock is taken as the last
step on handling disconnection (when the client is already sending
the next statement). Therefore, for the cases where the command
 --disconnect precedes the DROP USER statement
we hide the possible warnings about presence of active sessions
for the user being deleted to make tests deterministic.
2025-06-09 18:24:28 +07:00
..
mysql-test/disks MDEV-35617: DROP USER should leave no active session for that user 2025-06-09 18:24:28 +07:00
CMakeLists.txt MDEV-33093 plugin/disks/information_schema_disks.cc doesn't compile on Solaris 2024-01-10 10:10:31 +01:00
information_schema_disks.cc Fix typos in C comments in miscellaneous files 2025-03-24 13:36:28 +11:00
README.txt MDEV-14533 Provide information_schema tables using which hardware information can be obtained. 2018-03-23 00:55:19 +01:00

Information Schema Disks
------------------------
This is a proof-of-concept information schema plugin that allows the
disk space situation to be monitored. When installed, it can be used
as follows:

  > select * from information_schema.disks;
  +-----------+-----------------------+-----------+----------+-----------+
  | Disk      | Path                  | Total     | Used     | Available |
  +-----------+-----------------------+-----------+----------+-----------+
  | /dev/sda3 | /                     |  47929956 | 30666304 |  14805864 |
  | /dev/sda1 | /boot/efi             |    191551 |     3461 |    188090 |
  | /dev/sda4 | /home                 | 174679768 | 80335392 |  85448120 |
  | /dev/sdb1 | /mnt/hdd              | 961301832 |    83764 | 912363644 |
  | /dev/sdb1 | /home/wikman/Music    | 961301832 |    83764 | 912363644 |
  | /dev/sdb1 | /home/wikman/Videos   | 961301832 |    83764 | 912363644 |
  | /dev/sdb1 | /home/wikman/hdd      | 961301832 |    83764 | 912363644 |
  | /dev/sdb1 | /home/wikman/Pictures | 961301832 |    83764 | 912363644 |
  | /dev/sda3 | /var/lib/docker/aufs  |  47929956 | 30666304 |  14805864 |
  +-----------+-----------------------+-----------+----------+-----------+
  9 rows in set (0.00 sec)

- 'Disk' is the name of the disk itself.
- 'Path' is the mount point of the disk.
- 'Total' is the total space in KiB.
- 'Used' is the used amount of space in KiB, and
- 'Available' is the amount of space in KiB available to non-root users.

Note that as the amount of space available to root may be more that what
is available to non-root users, 'available' + 'used' may be less than 'total'.

All paths to which a particular disk has been mounted are reported. The
rationale is that someone might want to take different action e.g. depending
on which disk is relevant for a particular path. This leads to the same disk
being reported multiple times. An alternative to this would be to have two
tables; disks and mounts.

  > select * from information_schema.disks;
  +-----------+-----------+----------+-----------+
  | Disk      | Total     | Used     | Available |
  +-----------+-----------+----------+-----------+
  | /dev/sda3 |  47929956 | 30666304 |  14805864 |
  | /dev/sda1 |    191551 |     3461 |    188090 |
  | /dev/sda4 | 174679768 | 80335392 |  85448120 |
  | /dev/sdb1 | 961301832 |    83764 | 912363644 |
  +-----------+-----------+----------+-----------+

  > select * from information_schema.mounts;
  +-----------------------+-----------+
  | Path                  | Disk      |
  +-----------------------+-----------+
  | /                     | /dev/sda3 |
  | /boot/efi             | /dev/sda1 |
  | /home                 | /dev/sda4 |
  | /mnt/hdd              | /dev/sdb1 |
  | /home/wikman/Music    | /dev/sdb1 |
  ...


Installation
------------

- Use "install plugin" or "install soname" command:

  MariaDB [(none)]> install plugin disks soname 'disks.so';

  or

  MariaDB [(none)]> install soname 'disks.so';

Usage
-----
The plugin appears as the table 'disks' in 'information_schema'.

  MariaDB [(none)]> select * from information_schema.disks;
  +-----------+-----------------------+-----------+----------+-----------+
  | Disk      | Path                  | Total     | Used     | Available |
  +-----------+-----------------------+-----------+----------+-----------+
  | /dev/sda3 | /                     |  47929956 | 30666308 |  14805860 |
  | /dev/sda1 | /boot/efi             |    191551 |     3461 |    188090 |
  | /dev/sda4 | /home                 | 174679768 | 80348148 |  85435364 |
  | /dev/sdb1 | /mnt/hdd              | 961301832 |    83764 | 912363644 |
  | /dev/sdb1 | /home/wikman/Music    | 961301832 |    83764 | 912363644 |
  | /dev/sdb1 | /home/wikman/Videos   | 961301832 |    83764 | 912363644 |
  ...