apt-btrfs-snapshot creates nested snapshots that cannot be deleted easily

Bug #997909 reported by Sanjeev Gupta
This bug report is a duplicate of:  Bug #852458: three snapshots created. Edit Remove
90
This bug affects 19 people
Affects Status Importance Assigned to Milestone
apt-btrfs-snapshot (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Hi,

This is on a precise, with seperate / and /home , both fresh btrfs.

I have NO previous btrfs experience.

Some snapshots created automatically by apt-get upgrade cannot be deleted, others can.

See:
root@precise-X201:~# apt-btrfs-snapshot list
Available snapshots:
@apt-snapshot-2012-02-06_10:57:25
@apt-snapshot-2012-02-06_10:57:26
@apt-snapshot-2012-02-07_10:39:29
@apt-snapshot-2012-02-21_11:31:14
@apt-snapshot-2012-04-23_14:12:51
@apt-snapshot-2012-05-02_12:56:59
@apt-snapshot-2012-05-09_23:46:30
@apt-snapshot-2012-05-10_18:13:32
@apt-snapshot-2012-05-10_21:42:52
@apt-snapshot-2012-05-10_21:44:23
@apt-snapshot-2012-05-11_14:05:17

root@precise-X201:~# apt-btrfs-snapshot delete-older-than 1d
Delete subvolume '/tmp/apt-btrfs-snapshot-mp-AtGJCL/@apt-snapshot-2012-02-06_10:57:25'
ERROR: cannot delete '/tmp/apt-btrfs-snapshot-mp-AtGJCL/@apt-snapshot-2012-02-06_10:57:25'
Delete subvolume '/tmp/apt-btrfs-snapshot-mp-G7ba5C/@apt-snapshot-2012-02-06_10:57:26'
ERROR: cannot delete '/tmp/apt-btrfs-snapshot-mp-G7ba5C/@apt-snapshot-2012-02-06_10:57:26'
Delete subvolume '/tmp/apt-btrfs-snapshot-mp-rJFoU7/@apt-snapshot-2012-02-07_10:39:29'
ERROR: cannot delete '/tmp/apt-btrfs-snapshot-mp-rJFoU7/@apt-snapshot-2012-02-07_10:39:29'
Delete subvolume '/tmp/apt-btrfs-snapshot-mp-l0O8Tc/@apt-snapshot-2012-02-21_11:31:14'
ERROR: cannot delete '/tmp/apt-btrfs-snapshot-mp-l0O8Tc/@apt-snapshot-2012-02-21_11:31:14'
Delete subvolume '/tmp/apt-btrfs-snapshot-mp-NxuzYR/@apt-snapshot-2012-04-23_14:12:51'
ERROR: cannot delete '/tmp/apt-btrfs-snapshot-mp-NxuzYR/@apt-snapshot-2012-04-23_14:12:51'
Delete subvolume '/tmp/apt-btrfs-snapshot-mp-qTWNui/@apt-snapshot-2012-05-02_12:56:59'
ERROR: cannot delete '/tmp/apt-btrfs-snapshot-mp-qTWNui/@apt-snapshot-2012-05-02_12:56:59'
Delete subvolume '/tmp/apt-btrfs-snapshot-mp-C6mvol/@apt-snapshot-2012-05-09_23:46:30'
Delete subvolume '/tmp/apt-btrfs-snapshot-mp-WKrgPg/@apt-snapshot-2012-05-10_18:13:32'
Delete subvolume '/tmp/apt-btrfs-snapshot-mp-nSMmvC/@apt-snapshot-2012-05-10_21:42:52'
Delete subvolume '/tmp/apt-btrfs-snapshot-mp-H0UnbV/@apt-snapshot-2012-05-10_21:44:23'

root@precise-X201:~# apt-btrfs-snapshot list
Available snapshots:
@apt-snapshot-2012-02-06_10:57:25
@apt-snapshot-2012-02-06_10:57:26
@apt-snapshot-2012-02-07_10:39:29
@apt-snapshot-2012-02-21_11:31:14
@apt-snapshot-2012-04-23_14:12:51
@apt-snapshot-2012-05-02_12:56:59
@apt-snapshot-2012-05-11_14:05:17

I update daily, and cannot spot a pattern when and why some are "special".

--
Sanjeev Gupta

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: apt-btrfs-snapshot 0.2.1build1
ProcVersionSignature: Ubuntu 3.2.0-24.37-generic 3.2.14
Uname: Linux 3.2.0-24-generic x86_64
ApportVersion: 2.0.1-0ubuntu7
Architecture: amd64
Date: Fri May 11 14:04:41 2012
InstallationMedia: Ubuntu 12.04 LTS "Precise Pangolin" - Alpha amd64 (20111129.1)
PackageArchitecture: all
ProcEnviron:
 LANGUAGE=en_SG:en
 TERM=xterm
 PATH=(custom, no user)
 LANG=en_SG.UTF-8
 SHELL=/bin/bash
SourcePackage: apt-btrfs-snapshot
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Sanjeev Gupta (ghane) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in apt-btrfs-snapshot (Ubuntu):
status: New → Confirmed
Revision history for this message
Sanjeev Gupta (ghane) wrote :

Please see comment by MatthewHawn (steamraven) on Bug #852458

That describes this behaviour perfectly.

Revision history for this message
Sanjeev Gupta (ghane) wrote :

Hi,

Please see
  http://www.ogre.com/node/413
for a work-around.

Revision history for this message
Robert C. (fuzxxl) wrote :

As a possible workaround, you can attempt to delete those "inner" snapshots first. This worked for me to delete all apt-snapshots:

    for i in /@apt-* ; sudo btrfs sub del $i/@ ; sudo btrfs sub del $i

Revision history for this message
Jacek Nykis (jacekn) wrote :

Robert is rith in #6, here is what I did on my system to get rid of the snapshots:
mount /dev/sda1 /mnt/tmp #Mounted the same volume for the second time on a running system, can be done online
cd /mnt/tmp
btrfs subvolume list /mnt/tmp/
btrfs subvolume delete /mnt/tmp/@apt-snapshot-2013-01-01_12:42:41/@
btrfs subvolume delete /mnt/tmp/@apt-snapshot-2013-01-01_12:42:41

and repeated for all the other snapshots which would not disappear

Revision history for this message
Andrew Stubbs (ams-codesourcery) wrote :

The problem appear to be caused by multiple snapshots taken within the same second. See #852458.

Revision history for this message
Michael (auslands-kv) wrote :

I find it a pity that this long standing bug is still unassigned.

It is still not working correctly even under Ubuntu 14.04 :-(

I am wondering why we report bugs at all ...

Revision history for this message
Jonathan (jjcf89) wrote :

Creation of @ snapshot:

 $ sudo apt-btrfs-snapshot snapshot; sudo apt-btrfs-snapshot snapshot
Create a snapshot of '/tmp/apt-btrfs-snapshot-mp-r4lbis5q/@' in '/tmp/apt-btrfs-snapshot-mp-r4lbis5q/@apt-snapshot-2016-01-04_09:55:08'
Create a snapshot of '/tmp/apt-btrfs-snapshot-mp-vszwto5y/@' in '/tmp/apt-btrfs-snapshot-mp-vszwto5y/@apt-snapshot-2016-01-04_09:55:08/@'

Possible fix, not sure about name root_snapshot_dir though:

 $ diff /usr/lib/python3/dist-packages/apt_btrfs_snapshot.py.orig /usr/lib/python3/dist-packages/apt_btrfs_snapshot.py -u3
--- /usr/lib/python3/dist-packages/apt_btrfs_snapshot.py.orig 2016-01-04 09:48:53.632890479 -0500
+++ /usr/lib/python3/dist-packages/apt_btrfs_snapshot.py 2016-01-04 09:53:30.168895671 -0500
@@ -260,7 +260,15 @@

     def delete_snapshot(self, snapshot_name):
         mp = self.mount_btrfs_root_volume()
+ snapshot_dir = os.path.join(mp, snapshot_name)
+ # Check for @ snapshot inside snapshot. Need to delete this
+ # snapshot first if exists
+ root_snapshot_dir = os.path.join(snapshot_dir, "@")
+ if os.path.isdir(root_snapshot_dir):
+ res = self.commands.btrfs_delete_snapshot(
+ root_snapshot_dir)
+
         res = self.commands.btrfs_delete_snapshot(
- os.path.join(mp, snapshot_name))
+ snapshot_dir)
         self.umount_btrfs_root_volume()
         return res

 $ sudo apt-btrfs-snapshot delete @apt-snapshot-2016-01-04_09:55:08
Delete subvolume '/tmp/apt-btrfs-snapshot-mp-4g4167i8/@apt-snapshot-2016-01-04_09:55:08/@'
Delete subvolume '/tmp/apt-btrfs-snapshot-mp-4g4167i8/@apt-snapshot-2016-01-04_09:55:08'

Also create_btrfs_root_snapshot() could check for an existing snapshot and not create another one or add milliseconds to snapshot name.

Revision history for this message
Jonathan (jjcf89) wrote :
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "apt_btrfs_snapshot_fix_delete_snapshot.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Rolf Leggewie (r0lf)
summary: - apt-btrfs-snapshot creates snapshots that cannot be deleted
+ apt-btrfs-snapshot creates nested snapshots that cannot be deleted
summary: apt-btrfs-snapshot creates nested snapshots that cannot be deleted
+ easily
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.