Bug 1078336

Summary: snapper: snapshots lost on power loss
Product: [openSUSE] openSUSE Tumbleweed Reporter: Ignaz Forster <iforster>
Component: BasesystemAssignee: Arvin Schnell <aschnell>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Enhancement    
Priority: P4 - Low CC: aschnell, iforster
Version: CurrentFlags: aschnell: needinfo? (iforster)
Target Milestone: ---   
Hardware: Other   
OS: Other   
URL: https://trello.com/c/T0rphFVp/2053-opensuse-p4-1078336-snapper-snapshots-lost-on-power-loss
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: snapper with fsync calls
snapper with fsync calls

Description Ignaz Forster 2018-01-30 16:34:23 UTC
When creating a snapshot, e.g. with 'snapper create', and pulling the power cable immediately or soon after this, the snapshot will not be visible by 'snapper list'. The reason is that the information in /.snapshots/<number>/info.xml hasn't necessarily been synced onto the disk yet.

Steps to reproduce:
* `snapper create`
* `snapper list` (the snapshot is still listed)
* Pull the power cable / force shutdown of the VM
* Restart the machine
* `snapper list` (the snapshot is no longer visible)

This will cause problems in the future, as that snapshot won't be cleaned up automatically and will take more and more space due to Btrfs' CoW.

This could easily be avoided by syncing the metadata files (and - according to the manpage - also the newly created directories) to disk before actually creating the Btrfs snapshot (e.g. by using fsync).
Comment 1 Arvin Schnell 2018-02-01 10:02:55 UTC
I added a card to the YaST trello task board so that the issue is
prioritised with the other tasks.
Comment 2 Arvin Schnell 2020-08-24 11:58:07 UTC
I cannot reproduce the problem even if I shut down the virtual machine
within seconds after creating a snapshot. Real hardware for testing is
currently not available.

Please test the attached RPMs.
Comment 3 Arvin Schnell 2020-08-24 11:58:35 UTC
Created attachment 840981 [details]
snapper with fsync calls
Comment 4 Arvin Schnell 2020-08-24 11:58:57 UTC
Created attachment 840982 [details]
snapper with fsync calls
Comment 5 Arvin Schnell 2020-08-27 10:23:04 UTC
PR: https://github.com/openSUSE/snapper/pull/548
Comment 6 Arvin Schnell 2020-08-27 10:47:29 UTC
SR: https://build.opensuse.org/request/show/829955
Comment 7 Arvin Schnell 2020-08-27 10:49:47 UTC
Assuming that the issue is fixed by PR above.