Wrong locking type on local VG when clvm is used?
Hi list,
With clvm used in HA cluster, I find a interesting problem - LVM protects *local* VG with cluster-locking (locking_type = 3).
This may bring locking error on local VG "testvg", which can be easily reproduced as follows:
clvmd is running...
# mkdir loopdevs
# cd loopdevs/
# dd if=/dev/zero of=disk1.raw count=1 bs=1G
# dd if=/dev/zero of=disk2.raw count=1 bs=1G
# losetup -f disk1.raw
# losetup -f disk2.raw
# mdadm --create --verbose /dev/md0 --level=1 -N md0 -n2 /dev/loop0 /dev/loop1
# vgcreate -cn testvg /dev/md0
# lvcreate -l100%FREE --name testlv testvg
Logical volume "testlv" created.so far so good...
# lvchange -an testvg/testlv
# mdadm --stop /dev/md0
# pvscan or #clvmd -R to reload device cache
# mdadm --assemble --scan --name md0
# vgchange -ay testvg
Error locking on node 1302cf30: Volume group for uuid not found:
lG7H2DJXIg6EYzYOYs03mFSXodWK91YZJp3QGiLLF66s4uHtwRPxDKe0LXstR54iThe problem is:
1) local VG takes cluster-locking in such scenario, as you can see in init_locking();
2) clvmd daemon keeps a device cache itself (lvmetad can not be used with clvmd), so we need to refresh the device cache with 'clvmd -R' to reflect any device changes.
So, another workaround is to specify the locking_type on local VG in lvm command:
# vgchange -ay testvg --config 'global{locking_type=1}'
1 logical volume(s) in volume group "testvg" now activeLooking a bit at the code, LVM decides the locking_type on command basis, i.e. wrapping the command around with init_locking() and fin_locking(). So, I'm thinking if we can change locking_type selection to VG basis. For example, "vgchange -ay local_vg cluster_vg", we can decide the locking_type for each VG. Well, it's overkill if all the VGs are either local, or cluster... Is this reasonable, or something worth to do?
I really want to hear your comment before I start to work on this:-)
Regards,
Eric
Quoted 5 lines · Eric Ren
Looking a bit at the code, LVM decides the
locking_typeon command basis, i.e. wrapping the command around withinit_locking()andfin_locking(). So, I'm thinking if we can changelocking_typeselection to VG basis. For example, "vgchange -aylocal_vgcluster_vg", we can decide thelocking_typefor each VG. Well, it's overkill if all the VGs are either local, or cluster... Is this reasonable, or something worth to do?
Probably not - it's not really worth that level of complexity - we considered it several times before but always ruled it out. (We did tackle part of the difficulty when introducing lvmlockd though.) The workaround is easy - you already found one - and I thought the case you described used to work anyway (if the daemon couldn't find the object referenced it used to trigger a scan so it would find it) so it might just be needing some bug fix or varied configuration setting.
Alasdair
Hi!
Quoted 10 lines · Alasdair G Kergon
Quoted 5 lines · Eric Ren
Looking a bit at the code, LVM decides the
locking_typeon command basis, i.e. wrapping the command around withinit_locking()andfin_locking(). So, I'm thinking if we can changelocking_typeselection to VG basis. For example, "vgchange -aylocal_vgcluster_vg", we can decide thelocking_typefor each VG. Well, it's overkill if all the VGs are either local, or cluster... Is this reasonable, or something worth to do?Probably not - it's not really worth that level of complexity - we considered it several times before but always ruled it out. (We did tackle part of the difficulty when introducing lvmlockd though.) The workaround is easy - you already found one - and I thought the case you
Yes, thanks for sharing your thoughts!
Quoted 1 line
described used to work anyway (if the daemon couldn't find the object
Sorry, which daemon do you mean? clvmd or lvmetad...
It looks to me that lvmetad can do what you point out here. However, lvmetad is not used when clvm is in use, right? And, clvmd, seemingly, doesn't fail back to scan automatically. That's why 'clvmd -R' exists?
Quoted 2 lines
referenced it used to trigger a scan so it would find it) so it might just be needing some bug fix or varied configuration setting.
I tested on various versions including:
CentOS 7.3.1611 lvm2-2.02.166-1.el7_3.4.x86_64
SLE11/12 lvm2-2.02.120-72.8.x86_64
openSUSE Tumbleweed 20170510 lvm2-2.02.170-253.1.x86_64
This problem can be reproduced on all of them. For example, on centos:
[root at centos1 loopdevs]# vgchange -ay testvg
WARNING: Not using lvmetad because config setting use_lvmetad=0.
WARNING: To avoid corruption, rescan devices to make changes visible (pvscan --cache). Error locking on node 1: Volume group for uuid not found:
wYiWFAj64kucp3e7lgC5m9xtDGFNfwA82tsvS3TzuhXiiLWMknlNpBw1yf5YfVjr
So, I guess how to trigger clvmd to rescan when a object referenced couldn't be found, is I should look for:-)
Thanks very much for your input!
Eric
Quoted 9 lines
Alasdair
--
lvm-devel mailing list
lvm-devel at redhat.com
https://www.redhat.com/mailman/listinfo/lvm-devel