Checking lvm thinp metadata consumption before going ahead with snapshot create
The current snapshot implementation in Gluster mainly depends upon lvm snapshots.
One of the major issues that a user can face with the current lvm snapshots is lvm metadata thinpool running out of space. With more and more snapshots being taken (all of which are separate thin logical volumes sharing the same metadata thinpool) the metadata thinpool can run out of space before the hard limit of snapshots in gluster is reached. This leads to the regular bricks of the volume seeing errors when they perform IO on the local filesystem and can result in brick process returning error to the application (which the brick process got from the underlying disk filesystem, which itself got the error because of lvm thinpool metadata is full).
This requires manual intervention to create some space. So, one of the preventive checks that can be added in Gluster is to check for lvm thinpool metadata usage whenever glusterd receives a snapshot create command. If Say 80% or 90% of the thinpool metadata is full, then fail the snapshot create command with proper error message and log message. This atleast will help in preventing the problems that can arise later while accessing the main volume because of thinpool metadata being full.
One of the difficulties to check for the metadata consumption is availability of appropriate mechanism to do so. Currently, gluster makes use of lvm shell commands to manage snapshots (and not the LVM library). So, executing the command and then grepping for the relevant information there is not a trivial task within Glusterd. Therefore one thing that can be done is:
Write a script which executes the correct lv command to get the space consumption and grep for the metadata usage. The script will be called by glusterd in prevalidate phase (makes things simpler, otherwise, if the check is done in the op phase, some glusterds being able to take snapshots and some failing because of metadata space not being available creates problems while cleaning things up). Based on that, if atleast one of the glusterds complain about space not being available in thinpool metadata, fail the snapshot create operation with the error message. This is bit similar to how other operations such as volume start and volume stop make use of the scripts for doing additional operations.
NOTE: Probably the same script can be used by glusterd2 as well for doing prevalidation of incoming snapshot create requests.
Please provide feedback.
@rafikc30 @vbellur @amarts @sunnyku
@raghavendrabhat We have data percentage check in gd2, may be we can extend the same for metdata too.
I am not sure how, glusterd2 is doing lvm based checks (i.e. whether it is calling some LVM library APIs or simple shell commands. I assume it to be the latter i.e. shell commands).
Atleast I thought, doing grep magic on lvs (or vgs) family of commands to get metadata consumption might be not trivial. Atleast not in C (for current glusterd). If doing such checks is easy in glusterd2, then great. It greatly simplifies the things. Otherwise, probably a script can be consumed by glusterd2.
But, the intention is to check those things in prevalidate phase and fail the snapshot create op. This greatly helps admin in extending their thinpool metadata to avoid outage of access to their main volume. Script is a way to achieve this (probably more appropriate in current glusterd's context if not glusterd2). But doing such checks in glusterd2 is easier, then fine.
Thank you for your contributions. Noticed that this issue is not having any activity in last ~6 months! We are marking this issue as stale because it has not had recent activity. It will be closed in 2 weeks if no one responds with a comment here.
Closing this issue as there was no update since my last update on issue. If this is an issue which is still valid, feel free to open it.