Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2133901

Summary: lvremove -S|--select LV incorrectly removes just created associated historical LV in one go
Product: Red Hat Enterprise Linux 9 Reporter: Corey Marthaler <cmarthal>
Component: lvm2Assignee: Peter Rajnoha <prajnoha>
lvm2 sub component: Displaying and Reporting QA Contact: cluster-qe <cluster-qe>
Status: CLOSED ERRATA Docs Contact:
Severity: low    
Priority: unspecified CC: agk, heinzm, jbrassow, mcsontos, msnitzer, prajnoha, zkabelac
Version: 9.1Keywords: Reopened, Triaged
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: lvm2-2.03.17-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-09 08:23:45 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Corey Marthaler 2022-10-11 19:45:19 UTC
Description of problem:
I'm attempting to QA the "Tracking and displaying thin snapshot volumes that have been removed" Docs sections, and I can't get the feature to work. What am I doing wrong? I never see any "-" delete volumes.

[root@virt-529 ~]# grep history /etc/lvm/lvm.conf 
        # Configuration option shell/history_size.
        # Number of lines of history to store in ~/.lvm_history.
        # history_size = 100
        # Configuration option metadata/record_lvs_history.
        # When enabled, LVM keeps history records about removed LVs in
        record_lvs_history = 1
        # Configuration option metadata/lvs_history_retention_time.
        lvs_history_retention_time = 1



[root@virt-529 ~]# vgs
  VG            #PV #LV #SN Attr   VSize   VFree  
  rhel_virt-529   1   2   0 wz--n-  <7.00g      0 
  snapper_thinp   1   0   0 wz--n- <30.00g <30.00g
[root@virt-529 ~]# lvs -H -o name,full_ancestors,full_descendants
  LV      FAncestors                                                                            FDescendants                                                                          
  root                                                                                                                                                                                
  swap                                                                                                                                                                                
  POOL                                                                                                                                                                                
  origin                                                                                        stack1,stack2,stack3,stack4,stack5,stack6,stack7,stack8,stack9,stack10,stack11,stack12
  other1                                                                                                                                                                              
  other2                                                                                                                                                                              
  other3                                                                                                                                                                              
  other4                                                                                                                                                                              
  other5                                                                                                                                                                              
  stack1  origin                                                                                stack2,stack3,stack4,stack5,stack6,stack7,stack8,stack9,stack10,stack11,stack12       
  stack10 stack9,stack8,stack7,stack6,stack5,stack4,stack3,stack2,stack1,origin                 stack11,stack12                                                                       
  stack11 stack10,stack9,stack8,stack7,stack6,stack5,stack4,stack3,stack2,stack1,origin         stack12                                                                               
  stack12 stack11,stack10,stack9,stack8,stack7,stack6,stack5,stack4,stack3,stack2,stack1,origin                                                                                       
  stack2  stack1,origin                                                                         stack3,stack4,stack5,stack6,stack7,stack8,stack9,stack10,stack11,stack12              
  stack3  stack2,stack1,origin                                                                  stack4,stack5,stack6,stack7,stack8,stack9,stack10,stack11,stack12                     
  stack4  stack3,stack2,stack1,origin                                                           stack5,stack6,stack7,stack8,stack9,stack10,stack11,stack12                            
  stack5  stack4,stack3,stack2,stack1,origin                                                    stack6,stack7,stack8,stack9,stack10,stack11,stack12                                   
  stack6  stack5,stack4,stack3,stack2,stack1,origin                                             stack7,stack8,stack9,stack10,stack11,stack12                                          
  stack7  stack6,stack5,stack4,stack3,stack2,stack1,origin                                      stack8,stack9,stack10,stack11,stack12                                                 
  stack8  stack7,stack6,stack5,stack4,stack3,stack2,stack1,origin                               stack9,stack10,stack11,stack12                                                        
  stack9  stack8,stack7,stack6,stack5,stack4,stack3,stack2,stack1,origin                        stack10,stack11,stack12                                                               
[root@virt-529 ~]# #Now break the chain connection to the origin by removing the 1st and 2nd snap devices, and verify origin I/O continues to exist in the remaining snapshots
[root@virt-529 ~]# lvremove --yes --select 'lv_name=stack1 || origin=stack1'
  Logical volume "stack1" successfully removed.
  Logical volume "stack2" successfully removed.
  Historical logical volume "stack1" successfully removed.
[root@virt-529 ~]# lvs -H -o name,full_ancestors,full_descendants
  LV      FAncestors                                                       FDescendants                                                     
  root                                                                                                                                      
  swap                                                                                                                                      
  POOL                                                                                                                                      
  origin                                                                                                                                    
  other1                                                                                                                                    
  other2                                                                                                                                    
  other3                                                                                                                                    
  other4                                                                                                                                    
  other5                                                                                                                                    
  stack10 stack9,stack8,stack7,stack6,stack5,stack4,stack3                 stack11,stack12                                                  
  stack11 stack10,stack9,stack8,stack7,stack6,stack5,stack4,stack3         stack12                                                          
  stack12 stack11,stack10,stack9,stack8,stack7,stack6,stack5,stack4,stack3                                                                  
  stack3                                                                   stack4,stack5,stack6,stack7,stack8,stack9,stack10,stack11,stack12
  stack4  stack3                                                           stack5,stack6,stack7,stack8,stack9,stack10,stack11,stack12       
  stack5  stack4,stack3                                                    stack6,stack7,stack8,stack9,stack10,stack11,stack12              
  stack6  stack5,stack4,stack3                                             stack7,stack8,stack9,stack10,stack11,stack12                     
  stack7  stack6,stack5,stack4,stack3                                      stack8,stack9,stack10,stack11,stack12                            
  stack8  stack7,stack6,stack5,stack4,stack3                               stack9,stack10,stack11,stack12                                   
  stack9  stack8,stack7,stack6,stack5,stack4,stack3                        stack10,stack11,stack12                                          
[root@virt-529 ~]# lvs -H -o name,full_ancestors,full_descendants,time_removed
  LV      FAncestors                                                       FDescendants                                                      RTime                     
  root                                                                                                                                                                 
  swap                                                                                                                                                                 
  POOL                                                                                                                                                                 
  origin                                                                                                                                                               
  other1                                                                                                                                                               
  other2                                                                                                                                                               
  other3                                                                                                                                                               
  other4                                                                                                                                                               
  other5                                                                                                                                                               
  stack10 stack9,stack8,stack7,stack6,stack5,stack4,stack3                 stack11,stack12                                                                             
  stack11 stack10,stack9,stack8,stack7,stack6,stack5,stack4,stack3         stack12                                                                                     
  stack12 stack11,stack10,stack9,stack8,stack7,stack6,stack5,stack4,stack3                                                                                             
  stack3                                                                   stack4,stack5,stack6,stack7,stack8,stack9,stack10,stack11,stack12                           
  stack4  stack3                                                           stack5,stack6,stack7,stack8,stack9,stack10,stack11,stack12                                  
  stack5  stack4,stack3                                                    stack6,stack7,stack8,stack9,stack10,stack11,stack12                                         
  stack6  stack5,stack4,stack3                                             stack7,stack8,stack9,stack10,stack11,stack12                                                
  stack7  stack6,stack5,stack4,stack3                                      stack8,stack9,stack10,stack11,stack12                                                       
  stack8  stack7,stack6,stack5,stack4,stack3                               stack9,stack10,stack11,stack12                                                              
  stack9  stack8,stack7,stack6,stack5,stack4,stack3                        stack10,stack11,stack12                                                                     



Version-Release number of selected component (if applicable):
kernel-5.14.0-170.kpq1.el9    BUILT: Fri Sep 30 12:48:45 PM CEST 2022
lvm2-2.03.16-3.el9    BUILT: Mon Aug  1 11:42:35 AM CEST 2022
lvm2-libs-2.03.16-3.el9    BUILT: Mon Aug  1 11:42:35 AM CEST 2022

Comment 1 Peter Rajnoha 2022-10-12 10:28:08 UTC
(In reply to Corey Marthaler from comment #0)
> Description of problem:
> I'm attempting to QA the "Tracking and displaying thin snapshot volumes that
> have been removed" Docs sections, and I can't get the feature to work. What
> am I doing wrong? I never see any "-" delete volumes.
> 
> [root@virt-529 ~]# grep history /etc/lvm/lvm.conf 
>         # Configuration option shell/history_size.
>         # Number of lines of history to store in ~/.lvm_history.
>         # history_size = 100
>         # Configuration option metadata/record_lvs_history.
>         # When enabled, LVM keeps history records about removed LVs in
>         record_lvs_history = 1
>         # Configuration option metadata/lvs_history_retention_time.
>         lvs_history_retention_time = 1

You have lvs_history_retention_time set to 1 second - this will automatically cut out all historical LVs from output that were removed just 1 or more seconds ago. For LVM commands that don't change metadata (like reporting commands - "lvs"), this will only filter out such LVs from output, not metadata (so if you change the retention time appropriately, you can still see them). Then with the first LVM command that writes metadata, this will also remove associated records in metadata for such historical LVs.

Comment 2 Peter Rajnoha 2022-10-12 10:45:52 UTC
(In reply to Corey Marthaler from comment #0)
> [root@virt-529 ~]# #Now break the chain connection to the origin by removing
> the 1st and 2nd snap devices, and verify origin I/O continues to exist in
> the remaining snapshots
> [root@virt-529 ~]# lvremove --yes --select 'lv_name=stack1 || origin=stack1'
>   Logical volume "stack1" successfully removed.
>   Logical volume "stack2" successfully removed.
>   Historical logical volume "stack1" successfully removed.

...but here, it should have removed only "stack1" LV, not the "stack1" historical LV within the same command with select. Looks like the "select" has a list of LVs to traverse which also has the freshly removed LV appended at its end - this is probably a bug. I have to recheck how the list of LVs to process is prepared these days and fix this!

Comment 3 Peter Rajnoha 2022-10-12 13:23:50 UTC
I'm reusing this report to track the issue from comment #2, also changing the report title. This issue is now fixed with https://sourceware.org/git/?p=lvm2.git;a=commit;h=908555459f0abbcda687882439589209528e1dc0

Comment 4 Corey Marthaler 2022-10-12 15:10:45 UTC
(In reply to Peter Rajnoha from comment #2)
> (In reply to Corey Marthaler from comment #0)
> > [root@virt-529 ~]# #Now break the chain connection to the origin by removing
> > the 1st and 2nd snap devices, and verify origin I/O continues to exist in
> > the remaining snapshots
> > [root@virt-529 ~]# lvremove --yes --select 'lv_name=stack1 || origin=stack1'
> >   Logical volume "stack1" successfully removed.
> >   Logical volume "stack2" successfully removed.
> >   Historical logical volume "stack1" successfully removed.
> 
> ...but here, it should have removed only "stack1" LV, not the "stack1"
> historical LV within the same command with select. Looks like the "select"
> has a list of LVs to traverse which also has the freshly removed LV appended
> at its end - this is probably a bug. I have to recheck how the list of LVs
> to process is prepared these days and fix this!


I believe this is correct as stack1 was the origin for stack2. 'lv_name=stack1 || origin=stack1'

[root@virt-529 ~]# lvs -a -o +devices
  LV              VG            Attr       LSize   Pool Origin  Data%  Meta%  Move Log Cpy%Sync Convert Devices       
  POOL            snapper_thinp twi-aot---   1.00g              17.41  16.11                            POOL_tdata(0) 
  [POOL_tdata]    snapper_thinp Twi-ao----   1.00g                                                      /dev/sda(1)   
  [POOL_tmeta]    snapper_thinp ewi-ao----   4.00m                                                      /dev/sda(257) 
  [lvol0_pmspare] snapper_thinp ewi-------   4.00m                                                      /dev/sda(0)   
  origin          snapper_thinp Vwi-a-t---   1.00g POOL         15.12                                                 
  other1          snapper_thinp Vwi-a-t---   1.00g POOL         0.00                                                  
  other2          snapper_thinp Vwi-a-t---   1.00g POOL         0.00                                                  
  other3          snapper_thinp Vwi-a-t---   1.00g POOL         0.00                                                  
  other4          snapper_thinp Vwi-a-t---   1.00g POOL         0.00                                                  
  other5          snapper_thinp Vwi-a-t---   1.00g POOL         0.00                                                  
  stack1          snapper_thinp Vwi-a-t---   1.00g POOL origin  15.12                                                 
  stack10         snapper_thinp Vwi-aot---   1.00g POOL stack9  15.12                                                 
  stack11         snapper_thinp Vwi-aot---   1.00g POOL stack10 15.12                                                 
  stack12         snapper_thinp Vwi-aot---   1.00g POOL stack11 15.12                                                 
  stack2          snapper_thinp Vwi-a-t---   1.00g POOL stack1  15.12                                                 
  stack3          snapper_thinp Vwi-aot---   1.00g POOL stack2  15.12                                                 
  stack4          snapper_thinp Vwi-aot---   1.00g POOL stack3  15.12                                                 
  stack5          snapper_thinp Vwi-aot---   1.00g POOL stack4  15.12                                                 
  stack6          snapper_thinp Vwi-aot---   1.00g POOL stack5  15.12                                                 
  stack7          snapper_thinp Vwi-aot---   1.00g POOL stack6  15.12                                                 
  stack8          snapper_thinp Vwi-aot---   1.00g POOL stack7  15.12                                                 
  stack9          snapper_thinp Vwi-aot---   1.00g POOL stack8  15.12

Comment 5 Corey Marthaler 2022-10-12 15:12:38 UTC
Disregard my prior comment. You were talking about the "Historical logical volume "stack1" successfully removed." and not "Logical volume "stack2" successfully removed."

Comment 9 Corey Marthaler 2022-11-21 18:15:30 UTC
Marking Verified:Tested in the latest rpms.

kernel-5.14.0-192.kpq1.el9    BUILT: Fri Nov 11 08:34:24 AM CET 2022
lvm2-2.03.17-1.el9    BUILT: Thu Nov 10 05:02:16 PM CET 2022
lvm2-libs-2.03.17-1.el9    BUILT: Thu Nov 10 05:02:16 PM CET 2022


[root@virt-247 ~]# grep history /etc/lvm/lvm.conf 
        # Configuration option shell/history_size.
        # Number of lines of history to store in ~/.lvm_history.
        # history_size = 100
        # Configuration option metadata/record_lvs_history.
        # When enabled, LVM keeps history records about removed LVs in
        record_lvs_history = 1
        # Configuration option metadata/lvs_history_retention_time.
        lvs_history_retention_time = 1
[root@virt-247 ~]# lvs -H -o name,full_ancestors,full_descendants
  LV      FAncestors                                                                            FDescendants                                                                          
  root                                                                                                                                                                                
  swap                                                                                                                                                                                
  POOL                                                                                                                                                                                
  origin                                                                                        stack1,stack2,stack3,stack4,stack5,stack6,stack7,stack8,stack9,stack10,stack11,stack12
  other1                                                                                                                                                                              
  other2                                                                                                                                                                              
  other3                                                                                                                                                                              
  other4                                                                                                                                                                              
  other5                                                                                                                                                                              
  stack1  origin                                                                                stack2,stack3,stack4,stack5,stack6,stack7,stack8,stack9,stack10,stack11,stack12       
  stack10 stack9,stack8,stack7,stack6,stack5,stack4,stack3,stack2,stack1,origin                 stack11,stack12                                                                       
  stack11 stack10,stack9,stack8,stack7,stack6,stack5,stack4,stack3,stack2,stack1,origin         stack12                                                                               
  stack12 stack11,stack10,stack9,stack8,stack7,stack6,stack5,stack4,stack3,stack2,stack1,origin                                                                                       
  stack2  stack1,origin                                                                         stack3,stack4,stack5,stack6,stack7,stack8,stack9,stack10,stack11,stack12              
  stack3  stack2,stack1,origin                                                                  stack4,stack5,stack6,stack7,stack8,stack9,stack10,stack11,stack12                     
  stack4  stack3,stack2,stack1,origin                                                           stack5,stack6,stack7,stack8,stack9,stack10,stack11,stack12                            
  stack5  stack4,stack3,stack2,stack1,origin                                                    stack6,stack7,stack8,stack9,stack10,stack11,stack12                                   
  stack6  stack5,stack4,stack3,stack2,stack1,origin                                             stack7,stack8,stack9,stack10,stack11,stack12                                          
  stack7  stack6,stack5,stack4,stack3,stack2,stack1,origin                                      stack8,stack9,stack10,stack11,stack12                                                 
  stack8  stack7,stack6,stack5,stack4,stack3,stack2,stack1,origin                               stack9,stack10,stack11,stack12                                                        
  stack9  stack8,stack7,stack6,stack5,stack4,stack3,stack2,stack1,origin                        stack10,stack11,stack12                                                               
[root@virt-247 ~]# lvremove --yes --select 'lv_name=stack1 || origin=stack1'
  Logical volume "stack1" successfully removed.
  Logical volume "stack2" successfully removed.

Comment 14 Corey Marthaler 2023-01-12 19:25:00 UTC
Marking VERIFIED in the latest build as well.

kernel-5.14.0-229.el9    BUILT: Thu Jan  5 05:38:37 PM CET 2023
lvm2-2.03.17-4.el9    BUILT: Tue Jan 10 06:40:12 PM CET 2023
lvm2-libs-2.03.17-4.el9    BUILT: Tue Jan 10 06:40:12 PM CET 2023


[root@virt-540 ~]# lvremove --yes --select 'lv_name=stack1 || origin=stack1'
  Logical volume "stack1" successfully removed.
  Logical volume "stack2" successfully removed.

Comment 16 errata-xmlrpc 2023-05-09 08:23:45 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (lvm2 bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:2544